From 3a30f166d7e707be291d4e81ee6c4c67cd77e327 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Thu, 28 Jul 2016 20:17:07 +0200 Subject: [PATCH] :art: Signed-off-by: Nathan Sobo --- build/lib/package-application.js | 51 +++++++++++++++++--------------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/build/lib/package-application.js b/build/lib/package-application.js index e672a74ac..accf8e68d 100644 --- a/build/lib/package-application.js +++ b/build/lib/package-application.js @@ -22,35 +22,38 @@ module.exports = function () { 'platform': process.platform, 'version': CONFIG.appMetadata.electronVersion }, (err, packagedAppPaths) => { - if (err) { - console.error(err) - } else { - assert(packagedAppPaths.length === 1, 'Generated more than one electron application!') - const packagedAppPath = packagedAppPaths[0] - if (process.platform === 'darwin') { - const bundledResourcesPath = path.join(packagedAppPath, 'Atom.app', 'Contents', 'Resources') - const bundledShellCommandsPath = path.join(bundledResourcesPath, 'app') - console.log(`Copying shell commands to ${bundledShellCommandsPath}...`); - fs.copySync( - path.join(CONFIG.repositoryRootPath, 'apm', 'node_modules', 'atom-package-manager'), - path.join(bundledShellCommandsPath, 'apm'), - {filter: includePathInPackagedApp} - ) - if (process.platform !== 'windows') { - // Existing symlinks on user systems point to an outdated path, so just symlink it to the real location of the apm binary. - // TODO: Change command installer to point to appropriate path and remove this fallback after a few releases. - fs.symlinkSync(path.join('..', '..', 'bin', 'apm'), path.join(bundledShellCommandsPath, 'apm', 'node_modules', '.bin', 'apm')) - fs.copySync(path.join(CONFIG.repositoryRootPath, 'atom.sh'), path.join(bundledShellCommandsPath, 'atom.sh')) - } - } else { - throw new Error('TODO: handle this case!') - } + if (err) throw new Error(err) + assert(packagedAppPaths.length === 1, 'Generated more than one electron application!') - console.log(`Application bundle(s) created on ${packagedAppPath}`) + const packagedAppPath = packagedAppPaths[0] + let bundledResourcesPath + if (process.platform === 'darwin') { + bundledResourcesPath = path.join(packagedAppPath, 'Atom.app', 'Contents', 'Resources') + } else { + throw new Error('TODO: handle this case!') } + + copyShellCommands(bundledResourcesPath) + console.log(`Application bundle(s) created on ${packagedAppPath}`) }) } +function copyShellCommands (bundledResourcesPath) { + const bundledShellCommandsPath = path.join(bundledResourcesPath, 'app') + console.log(`Copying shell commands to ${bundledShellCommandsPath}...`); + fs.copySync( + path.join(CONFIG.repositoryRootPath, 'apm', 'node_modules', 'atom-package-manager'), + path.join(bundledShellCommandsPath, 'apm'), + {filter: includePathInPackagedApp} + ) + if (process.platform !== 'win32') { + // Existing symlinks on user systems point to an outdated path, so just symlink it to the real location of the apm binary. + // TODO: Change command installer to point to appropriate path and remove this fallback after a few releases. + fs.symlinkSync(path.join('..', '..', 'bin', 'apm'), path.join(bundledShellCommandsPath, 'apm', 'node_modules', '.bin', 'apm')) + fs.copySync(path.join(CONFIG.repositoryRootPath, 'atom.sh'), path.join(bundledShellCommandsPath, 'atom.sh')) + } +} + function buildAsarUnpackGlobExpression () { const unpack = [ '*.node',