mirror of
https://github.com/Llewellynvdm/nativefier.git
synced 2024-12-22 10:08:55 +00:00
hoist + reorganize code from #7, and use fs.rename instead of spawn mv
This commit is contained in:
parent
24f0476eeb
commit
cbc585393b
30
index.js
30
index.js
@ -89,23 +89,27 @@ module.exports = function packager (opts, cb) {
|
||||
ncp(opts.dir, paths.app, {filter: filter}, function copied (err) {
|
||||
if (err) return cb(err)
|
||||
|
||||
function moveApp (err) {
|
||||
if (err) return cb(err)
|
||||
|
||||
// finally, move app into cwd
|
||||
var finalPath = opts.out || process.cwd()
|
||||
// TODO dont spawn, but I couldn't find a good module
|
||||
child.exec('mv "' + newApp + '" "' + finalPath + '"', function moved (err) {
|
||||
cb(err, path.join(finalPath, opts.name + '.app'))
|
||||
})
|
||||
}
|
||||
|
||||
// run npm prune
|
||||
if (opts.prune) {
|
||||
child.exec('npm prune --production', { cwd: paths.app }, moveApp)
|
||||
prune(function pruned (err) {
|
||||
if (err) return cb(err)
|
||||
moveApp()
|
||||
})
|
||||
} else {
|
||||
moveApp()
|
||||
}
|
||||
|
||||
function prune (cb) {
|
||||
child.exec('npm prune --production', { cwd: paths.app }, cb)
|
||||
}
|
||||
|
||||
function moveApp () {
|
||||
// finally, move app into cwd
|
||||
var finalPath = path.join(opts.out || process.cwd(), opts.name + '.app')
|
||||
|
||||
fs.rename(newApp, finalPath, function moved (err) {
|
||||
cb(err, finalPath)
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user