Merge branch 'master' into tree-sitter-injections

This commit is contained in:
Max Brunsfeld
2018-07-13 16:10:19 -07:00
47 changed files with 1025 additions and 72 deletions

View File

@@ -487,21 +487,25 @@ class AtomEnvironment {
// Public: Gets the release channel of the Atom application.
//
// Returns the release channel as a {String}. Will return one of `dev`, `beta`, or `stable`.
// Returns the release channel as a {String}. Will return a specific release channel
// name like 'beta' or 'nightly' if one is found in the Atom version or 'stable'
// otherwise.
getReleaseChannel () {
const version = this.getVersion()
if (version.includes('beta')) {
return 'beta'
} else if (version.includes('dev')) {
return 'dev'
} else {
return 'stable'
// This matches stable, dev (with or without commit hash) and any other
// release channel following the pattern '1.00.0-channel0'
const match = this.getVersion().match(/\d+\.\d+\.\d+(-([a-z]+)(\d+|-\w{4,})?)?$/)
if (!match) {
return 'unrecognized'
} else if (match[2]) {
return match[2]
}
return 'stable'
}
// Public: Returns a {Boolean} that is `true` if the current version is an official release.
isReleasedVersion () {
return !/\w{7}/.test(this.getVersion()) // Check if the release is a 7-character SHA prefix
return this.getReleaseChannel().match(/stable|beta|nightly/) != null
}
// Public: Get the time taken to completely load the current window.

View File

@@ -27,22 +27,36 @@ 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) {
let channelMatch = this.appVersion.match(/beta|nightly/)
let channel = channelMatch ? channelMatch[0] : ''
switch (channel) {
case 'beta':
return `${commandName}-beta`
case 'nightly':
return `${commandName}-nightly`
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 +65,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 +78,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)
}

View File

@@ -12,13 +12,18 @@ module.exports = function parseCommandLine (processArgs) {
options.usage(
dedent`Atom Editor v${version}
Usage: atom [options] [path ...]
Usage:
atom [options] [path ...]
atom file[:line[:column]]
One or more paths to files or folders may be specified. If there is an
existing Atom window that contains all of the given folders, the paths
will be opened in that window. Otherwise, they will be opened in a new
window.
A file may be opened at the desired line (and optionally column) by
appending the numbers right after the file name, e.g. \`atom file:5:8\`.
Paths that start with \`atom://\` will be interpreted as URLs.
Environment Variables:

View File

@@ -153,9 +153,11 @@ class TooltipManager {
}
window.addEventListener('resize', hideTooltip)
window.addEventListener('keydown', hideTooltip)
const disposable = new Disposable(() => {
window.removeEventListener('resize', hideTooltip)
window.removeEventListener('keydown', hideTooltip)
hideTooltip()
tooltip.destroy()