mirror of
https://github.com/Llewellynvdm/nativefier.git
synced 2024-11-04 20:38:03 +00:00
Move prune to common module
This commit is contained in:
parent
16b2feb39f
commit
bdc8c46362
12
common.js
12
common.js
@ -1,4 +1,5 @@
|
||||
var asar = require('asar')
|
||||
var child = require('child_process')
|
||||
var path = require('path')
|
||||
var rimraf = require('rimraf')
|
||||
|
||||
@ -15,6 +16,17 @@ module.exports = {
|
||||
})
|
||||
},
|
||||
|
||||
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()
|
||||
}
|
||||
},
|
||||
|
||||
userIgnoreFilter: function userIgnoreFilter (opts, is_win32, finalDir) {
|
||||
return function filter (file) {
|
||||
if (is_win32) {
|
||||
|
14
linux.js
14
linux.js
@ -1,6 +1,5 @@
|
||||
var path = require('path')
|
||||
var fs = require('fs')
|
||||
var child = require('child_process')
|
||||
var mkdirp = require('mkdirp')
|
||||
var ncp = require('ncp').ncp
|
||||
var common = require('./common')
|
||||
@ -29,14 +28,7 @@ module.exports = {
|
||||
function copyUserApp () {
|
||||
ncp(opts.dir, userAppDir, {filter: common.userIgnoreFilter(opts, false, finalDir), dereference: true}, function copied (err) {
|
||||
if (err) return cb(err)
|
||||
if (opts.prune) {
|
||||
prune(function pruned (err) {
|
||||
if (err) return cb(err)
|
||||
renameElectronBinary()
|
||||
})
|
||||
} else {
|
||||
renameElectronBinary()
|
||||
}
|
||||
common.prune(opts, userAppDir, cb, renameElectronBinary)
|
||||
})
|
||||
}
|
||||
|
||||
@ -51,10 +43,6 @@ module.exports = {
|
||||
})
|
||||
}
|
||||
|
||||
function prune (cb) {
|
||||
child.exec('npm prune --production', { cwd: userAppDir }, cb)
|
||||
}
|
||||
|
||||
function appFilter (file) {
|
||||
return file.match(/default_app/) === null
|
||||
}
|
||||
|
15
mac.js
15
mac.js
@ -72,19 +72,6 @@ function buildMacApp (opts, cb, newApp) {
|
||||
ncp(opts.dir, paths.app, {filter: common.userIgnoreFilter(opts), dereference: true}, function copied (err) {
|
||||
if (err) return cb(err)
|
||||
|
||||
if (opts.prune) {
|
||||
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 outdir = opts.out || process.cwd()
|
||||
@ -134,5 +121,7 @@ function buildMacApp (opts, cb, newApp) {
|
||||
cb(err, appPath)
|
||||
})
|
||||
}
|
||||
|
||||
common.prune(opts, paths.app, cb, moveApp)
|
||||
})
|
||||
}
|
||||
|
16
win32.js
16
win32.js
@ -1,6 +1,5 @@
|
||||
var os = require('os')
|
||||
var path = require('path')
|
||||
var child = require('child_process')
|
||||
|
||||
var mkdirp = require('mkdirp')
|
||||
var rimraf = require('rimraf')
|
||||
@ -54,19 +53,6 @@ function buildWinApp (opts, cb, newApp) {
|
||||
ncp(opts.dir, paths.app, {filter: common.userIgnoreFilter(opts, true), dereference: true}, function copied (err) {
|
||||
if (err) return cb(err)
|
||||
|
||||
if (opts.prune) {
|
||||
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 + '-win32')
|
||||
@ -97,5 +83,7 @@ function buildWinApp (opts, cb, newApp) {
|
||||
cb(err, finalPath)
|
||||
})
|
||||
}
|
||||
|
||||
common.prune(opts, paths.app, cb, moveApp)
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user