mirror of
https://github.com/Llewellynvdm/nativefier.git
synced 2025-01-09 08:30:15 +00:00
Add asar support. Closes GH-2
This commit is contained in:
parent
a930bebaf3
commit
a2abf5ed6c
16
linux.js
16
linux.js
@ -3,6 +3,8 @@ 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')
|
||||
|
||||
module.exports = {
|
||||
createApp: function createApp (opts, cb, electronPath) {
|
||||
@ -43,6 +45,11 @@ module.exports = {
|
||||
function renameElectronBinary () {
|
||||
fs.rename(originalBinary, finalBinary, function electronRenamed (err) {
|
||||
if (err) return cb(err)
|
||||
if (opts.asar) {
|
||||
asarApp(cb)
|
||||
} else {
|
||||
cb()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@ -66,6 +73,15 @@ 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, cb)
|
||||
})
|
||||
}
|
||||
|
||||
copyApp()
|
||||
}
|
||||
}
|
||||
|
18
mac.js
18
mac.js
@ -7,6 +7,7 @@ var plist = require('plist')
|
||||
var mkdirp = require('mkdirp')
|
||||
var rimraf = require('rimraf')
|
||||
var ncp = require('ncp').ncp
|
||||
var asar = require('asar')
|
||||
|
||||
module.exports = {
|
||||
createApp: function createApp (opts, cb, electronPath) {
|
||||
@ -100,9 +101,16 @@ function buildMacApp (opts, cb, newApp) {
|
||||
var finalPath = path.join(opts.out || process.cwd(), opts.name + '.app')
|
||||
|
||||
fs.rename(newApp, finalPath, function moved (err) {
|
||||
if (err) return cb(err)
|
||||
if (opts.asar) {
|
||||
asarApp(function (err) {
|
||||
if (err) return cb(err)
|
||||
updateMacIcon()
|
||||
})
|
||||
} else {
|
||||
updateMacIcon()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function updateMacIcon () {
|
||||
@ -116,5 +124,15 @@ function buildMacApp (opts, cb, newApp) {
|
||||
cb(err, finalPath)
|
||||
})
|
||||
}
|
||||
|
||||
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)
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
},
|
||||
"homepage": "https://github.com/maxogden/electron-packager",
|
||||
"dependencies": {
|
||||
"asar": "^0.6.1",
|
||||
"minimist": "^1.1.1",
|
||||
"mkdirp": "^0.5.0",
|
||||
"ncp": "^2.0.0",
|
||||
|
Loading…
Reference in New Issue
Block a user