Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change electron-packager from callback to promises #1673

Merged
merged 2 commits into from
Sep 6, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 18 additions & 14 deletions bin/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,7 @@ function buildDarwin (cb) {
const plist = require('plist')

console.log('Mac: Packaging electron...')
electronPackager(Object.assign({}, all, darwin), function (err, buildPath) {
if (err) return cb(err)
electronPackager(Object.assign({}, all, darwin)).then(function (buildPath) {
console.log('Mac: Packaged electron. ' + buildPath)

const appPath = path.join(buildPath[0], config.APP_NAME + '.app')
Expand Down Expand Up @@ -356,6 +355,8 @@ function buildDarwin (cb) {
cb(null)
})
}
}).catch(function (err) {
cb(err)
})
}

Expand All @@ -376,8 +377,7 @@ function buildWin32 (cb) {
CERT_PATH = path.join(os.homedir(), 'Desktop')
}

electronPackager(Object.assign({}, all, win32), function (err, buildPath) {
if (err) return cb(err)
electronPackager(Object.assign({}, all, win32)).then(function (buildPath) {
console.log('Windows: Packaged electron. ' + buildPath)

let signWithParams
Expand Down Expand Up @@ -406,7 +406,7 @@ function buildWin32 (cb) {
series(tasks, cb)

function packageInstaller (filesPath, cb) {
console.log(`Windows: Creating installer...`)
console.log('Windows: Creating installer...')

installer.createWindowsInstaller({
appDirectory: filesPath,
Expand Down Expand Up @@ -437,7 +437,7 @@ function buildWin32 (cb) {
version: pkg.version
})
.then(function () {
console.log(`Windows: Created installer.`)
console.log('Windows: Created installer.')

/**
* Delete extraneous Squirrel files (i.e. *.nupkg delta files for older
Expand All @@ -455,7 +455,7 @@ function buildWin32 (cb) {
}

function packagePortable (filesPath, cb) {
console.log(`Windows: Creating portable app...`)
console.log('Windows: Creating portable app...')

const portablePath = path.join(filesPath, 'Portable Settings')
mkdirp.sync(portablePath)
Expand All @@ -470,16 +470,18 @@ function buildWin32 (cb) {
const outPath = path.join(DIST_PATH, BUILD_NAME + '-win.zip')
zip.zipSync(inPath, outPath)

console.log(`Windows: Created portable app.`)
console.log('Windows: Created portable app.')
cb(null)
}
}).catch(function (err) {
cb(err)
})
}

function buildLinux (cb) {
console.log('Linux: Packaging electron...')
electronPackager(Object.assign({}, all, linux), function (err, buildPath) {
if (err) return cb(err)

electronPackager(Object.assign({}, all, linux)).then(function (buildPath) {
console.log('Linux: Packaged electron. ' + buildPath)

const tasks = []
Expand All @@ -492,11 +494,13 @@ function buildLinux (cb) {
}
})
series(tasks, cb)
}).catch(function (err) {
cb(err)
})

function packageDeb (filesPath, cb) {
// Create .deb file for Debian-based platforms
console.log(`Linux: Creating deb...`)
console.log('Linux: Creating deb...')

const deb = require('nobin-debian-installer')()
const destPath = path.join('/opt', pkg.name)
Expand Down Expand Up @@ -524,20 +528,20 @@ function buildLinux (cb) {
cwd: path.join(config.STATIC_PATH, 'linux', 'share')
}], function (err) {
if (err) return cb(err)
console.log(`Linux: Created deb.`)
console.log('Linux: Created deb.')
cb(null)
})
}

function packageZip (filesPath, cb) {
// Create .zip file for Linux
console.log(`Linux: Creating zip...`)
console.log('Linux: Creating zip...')

const inPath = path.join(DIST_PATH, path.basename(filesPath))
const outPath = path.join(DIST_PATH, BUILD_NAME + '-linux.zip')
zip.zipSync(inPath, outPath)

console.log(`Linux: Created zip.`)
console.log('Linux: Created zip.')
cb(null)
}
}
Expand Down