mirror of
https://github.com/atom/atom.git
synced 2026-02-16 17:45:24 -05:00
Command installer should use known channel names
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user