2015-06-10 02:17:21 +00:00
|
|
|
var asar = require('asar')
|
2015-06-10 02:30:43 +00:00
|
|
|
var child = require('child_process')
|
2015-06-10 02:17:21 +00:00
|
|
|
var path = require('path')
|
|
|
|
var rimraf = require('rimraf')
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
asarApp: function asarApp (finalDir, cb) {
|
|
|
|
var src = path.join(finalDir, 'resources', 'app')
|
|
|
|
var dest = path.join(finalDir, 'resources', 'app.asar')
|
|
|
|
asar.createPackage(src, dest, function (err) {
|
|
|
|
if (err) return cb(err)
|
|
|
|
rimraf(src, function (err) {
|
|
|
|
if (err) return cb(err)
|
|
|
|
cb(null, dest)
|
|
|
|
})
|
|
|
|
})
|
2015-06-10 02:26:55 +00:00
|
|
|
},
|
|
|
|
|
2015-06-10 02:30:43 +00:00
|
|
|
prune: function prune (opts, cwd, cb, nextStep) {
|
|
|
|
if (opts.prune) {
|
|
|
|
child.exec('npm prune --production', { cwd: cwd }, function pruned (err) {
|
|
|
|
if (err) return cb(err)
|
|
|
|
nextStep()
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
nextStep()
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2015-06-10 02:26:55 +00:00
|
|
|
userIgnoreFilter: function userIgnoreFilter (opts, is_win32, finalDir) {
|
|
|
|
return function filter (file) {
|
|
|
|
if (is_win32) {
|
|
|
|
// convert slashes so unix-format ignores work
|
|
|
|
file = file.replace(/\\/g, '/')
|
|
|
|
}
|
|
|
|
|
|
|
|
var ignore = opts.ignore || []
|
|
|
|
if (!Array.isArray(ignore)) ignore = [ignore]
|
|
|
|
if (typeof finalDir !== 'undefined') {
|
|
|
|
ignore = ignore.concat([finalDir])
|
|
|
|
}
|
|
|
|
for (var i = 0; i < ignore.length; i++) {
|
|
|
|
if (file.match(ignore[i])) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|
2015-06-10 02:17:21 +00:00
|
|
|
}
|
|
|
|
}
|