Merge branch 'tengyifei-master'

This commit is contained in:
Max Ogden 2015-06-27 19:26:07 -05:00
commit e01849fbf3
3 changed files with 49 additions and 17 deletions

2
cli.js
View File

@ -1,6 +1,6 @@
#!/usr/bin/env node
var fs = require('fs')
var args = require('minimist')(process.argv.slice(2), {boolean: ['prune', 'asar']})
var args = require('minimist')(process.argv.slice(2), {boolean: ['prune', 'asar', 'overwrite']})
var packager = require('./')
var usage = fs.readFileSync(__dirname + '/usage.txt').toString()

View File

@ -2,6 +2,7 @@ var path = require('path')
var fs = require('fs')
var mkdirp = require('mkdirp')
var ncp = require('ncp').ncp
var rimraf = require('rimraf')
var common = require('./common')
module.exports = {
@ -12,10 +13,25 @@ module.exports = {
var finalBinary = path.join(finalDir, opts.name)
function copyApp () {
mkdirp(finalDir, function AppFolderCreated (err) {
var createApp = function (err) {
if (err) return cb(err)
copyAppTemplate()
})
mkdirp(finalDir, function AppFolderCreated (err) {
if (err) return cb(err)
copyAppTemplate()
})
}
if (opts.overwrite) {
fs.exists(finalDir, function (exists) {
if (exists) {
console.log('Overwriting existing ' + finalDir + ' ...')
rimraf(finalDir, createApp)
} else {
createApp()
}
})
} else {
createApp()
}
}
function copyAppTemplate () {

42
mac.js
View File

@ -80,24 +80,40 @@ function buildMacApp (opts, cb, newApp) {
mkdirp(outdir, function mkoutdirp () {
if (err) return cb(err)
mv(newApp, finalPath, function moved (err) {
if (opts.overwrite) {
fs.exists(finalPath, function (exists) {
if (exists) {
console.log('Overwriting existing ' + finalPath + ' ...')
rimraf(finalPath, deploy)
} else {
deploy()
}
})
} else {
deploy()
}
function deploy (err) {
if (err) return cb(err)
if (opts.asar) {
var finalPath = path.join(opts.out || process.cwd(), opts.name + '.app', 'Contents', 'Resources')
common.asarApp(finalPath, function (err) {
if (err) return cb(err)
mv(newApp, finalPath, function moved (err) {
if (err) return cb(err)
if (opts.asar) {
var finalPath = path.join(opts.out || process.cwd(), opts.name + '.app', 'Contents', 'Resources')
common.asarApp(finalPath, function (err) {
if (err) return cb(err)
updateMacIcon(function (err) {
if (err) return cb(err)
codesign()
})
})
} else {
updateMacIcon(function (err) {
if (err) return cb(err)
codesign()
})
})
} else {
updateMacIcon(function (err) {
if (err) return cb(err)
codesign()
})
}
})
}
})
}
})
}