From 691d5da97cc1722050c2d1bae44a69b3d09f9e14 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Tue, 26 Jun 2018 17:06:15 -0700 Subject: [PATCH] Command installer should use known channel names --- src/command-installer.js | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/command-installer.js b/src/command-installer.js index 85360da17..29375d382 100644 --- a/src/command-installer.js +++ b/src/command-installer.js @@ -27,22 +27,35 @@ class CommandInstaller { }, () => {}) } - this.installAtomCommand(true, error => { + this.installAtomCommand(true, (error, atomCommandName) => { if (error) return showErrorDialog(error) - this.installApmCommand(true, error => { + this.installApmCommand(true, (error, apmCommandName) => { if (error) return showErrorDialog(error) this.applicationDelegate.confirm({ message: 'Commands installed.', - detail: 'The shell commands `atom` and `apm` are installed.' + detail: `The shell commands '${atomCommandName}' and '${apmCommandName}' are installed.` }, () => {}) }) }) } + getCommandNameForChannel (commandName) { + switch (atom.getReleaseChannel()) { + case 'beta': + return `${commandName}-beta` + case 'nightly': + return `${commandName}-nightly` + case 'dev': + return `${commandName}-dev` + default: + return commandName + } + } + installAtomCommand (askForPrivilege, callback) { this.installCommand( path.join(this.getResourcesDirectory(), 'app', 'atom.sh'), - this.appVersion.includes('beta') ? 'atom-beta' : 'atom', + this.getCommandNameForChannel('atom'), askForPrivilege, callback ) @@ -51,7 +64,7 @@ class CommandInstaller { installApmCommand (askForPrivilege, callback) { this.installCommand( path.join(this.getResourcesDirectory(), 'app', 'apm', 'node_modules', '.bin', 'apm'), - this.appVersion.includes('beta') ? 'apm-beta' : 'apm', + this.getCommandNameForChannel('apm'), askForPrivilege, callback ) @@ -64,11 +77,11 @@ class CommandInstaller { fs.readlink(destinationPath, (error, realpath) => { if (error && error.code !== 'ENOENT') return callback(error) - if (realpath === commandPath) return callback() + if (realpath === commandPath) return callback(null, commandName) this.createSymlink(fs, commandPath, destinationPath, error => { if (error && error.code === 'EACCES' && askForPrivilege) { const fsAdmin = require('fs-admin') - this.createSymlink(fsAdmin, commandPath, destinationPath, callback) + this.createSymlink(fsAdmin, commandPath, destinationPath, (error) => { callback(error, commandName) }) } else { callback(error) }