2
2
mirror of https://github.com/Llewellynvdm/nativefier.git synced 2024-12-23 02:28:55 +00:00

Move asar code to a common location

This commit is contained in:
Mark Lee 2015-06-09 19:17:21 -07:00
parent 5f3704cdf5
commit 83dd1dcb34
4 changed files with 25 additions and 40 deletions

17
common.js Normal file
View File

@ -0,0 +1,17 @@
var asar = require('asar')
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)
})
})
}
}

View File

@ -3,8 +3,7 @@ var fs = require('fs')
var child = require('child_process')
var mkdirp = require('mkdirp')
var ncp = require('ncp').ncp
var rimraf = require('rimraf')
var asar = require('asar')
var common = require('./common')
module.exports = {
createApp: function createApp (opts, templateApp, cb) {
@ -45,7 +44,7 @@ module.exports = {
fs.rename(originalBinary, finalBinary, function electronRenamed (err) {
if (err) return cb(err)
if (opts.asar) {
asarApp(cb)
common.asarApp(finalDir, cb)
} else {
cb(null, finalBinary)
}
@ -72,18 +71,6 @@ module.exports = {
return true
}
function asarApp (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)
})
})
}
copyApp()
}
}

15
mac.js
View File

@ -7,7 +7,7 @@ var plist = require('plist')
var mkdirp = require('mkdirp')
var rimraf = require('rimraf')
var ncp = require('ncp').ncp
var asar = require('asar')
var common = require('./common')
module.exports = {
createApp: function createApp (opts, electronPath, cb) {
@ -106,7 +106,8 @@ function buildMacApp (opts, cb, newApp) {
fs.rename(newApp, finalPath, function moved (err) {
if (err) return cb(err)
if (opts.asar) {
asarApp(function (err) {
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)
@ -135,16 +136,6 @@ function buildMacApp (opts, cb, newApp) {
})
}
function asarApp (cb) {
var finalPath = path.join(opts.out || process.cwd(), opts.name + '.app', 'Contents', 'Resources')
var src = path.join(finalPath, 'app')
var dest = path.join(finalPath, 'app.asar')
asar.createPackage(src, dest, function (err) {
if (err) return cb(err)
rimraf(src, cb)
})
}
function codesign () {
var appPath = path.join(opts.out || process.cwd(), opts.name + '.app')

View File

@ -5,9 +5,9 @@ var child = require('child_process')
var mkdirp = require('mkdirp')
var rimraf = require('rimraf')
var ncp = require('ncp').ncp
var asar = require('asar')
var mv = require('mv')
var rcedit = require('rcedit')
var common = require('./common')
module.exports = {
createApp: function createApp (opts, electronApp, cb) {
@ -87,7 +87,8 @@ function buildWinApp (opts, cb, newApp) {
copy(newApp, finalPath, function moved (err) {
if (err) return cb(err)
if (opts.asar) {
asarApp(function (err) {
var finalPath = path.join(opts.out || process.cwd(), opts.name + '-win32', 'resources')
common.asarApp(finalPath, function (err) {
if (err) return cb(err)
updateIcon()
})
@ -109,17 +110,6 @@ function buildWinApp (opts, cb, newApp) {
rcedit(exePath, {icon: opts.icon}, function (err) {
cb(err, finalPath)
})
}
function asarApp (cb) {
var finalPath = path.join(opts.out || process.cwd(), opts.name + '-win32', 'resources')
var src = path.join(finalPath, 'app')
var dest = path.join(finalPath, 'app.asar')
asar.createPackage(src, dest, function (err) {
if (err) return cb(err)
rimraf(src, cb)
})
}
})
}