mirror of https://github.com/atom/atom.git
Re-apply prettier JS formatter
This commit is contained in:
parent
79f6836349
commit
e213a69a1f
|
@ -19,12 +19,14 @@ const homeDirPath = process.env.HOME || process.env.USERPROFILE;
|
|||
const atomHomeDirPath =
|
||||
process.env.ATOM_HOME || path.join(homeDirPath, '.atom');
|
||||
|
||||
const appMetadata = require(path.join(repositoryRootPath, 'package.json'))
|
||||
const apmMetadata = require(path.join(apmRootPath, 'package.json'))
|
||||
const computedAppVersion = computeAppVersion(process.env.ATOM_RELEASE_VERSION || appMetadata.version)
|
||||
const channel = getChannel(computedAppVersion)
|
||||
const appName = getAppName(channel)
|
||||
const executableName = getExecutableName(channel, appName)
|
||||
const appMetadata = require(path.join(repositoryRootPath, 'package.json'));
|
||||
const apmMetadata = require(path.join(apmRootPath, 'package.json'));
|
||||
const computedAppVersion = computeAppVersion(
|
||||
process.env.ATOM_RELEASE_VERSION || appMetadata.version
|
||||
);
|
||||
const channel = getChannel(computedAppVersion);
|
||||
const appName = getAppName(channel);
|
||||
const executableName = getExecutableName(channel, appName);
|
||||
|
||||
module.exports = {
|
||||
appMetadata,
|
||||
|
@ -66,17 +68,17 @@ function getAppName(channel) {
|
|||
channel.charAt(0).toUpperCase() + channel.slice(1)}`;
|
||||
}
|
||||
|
||||
function getExecutableName (channel, appName) {
|
||||
function getExecutableName(channel, appName) {
|
||||
if (process.platform === 'darwin') {
|
||||
return appName
|
||||
return appName;
|
||||
} else if (process.platform === 'win32') {
|
||||
return channel === 'stable' ? 'atom.exe' : `atom-${channel}.exe`
|
||||
return channel === 'stable' ? 'atom.exe' : `atom-${channel}.exe`;
|
||||
} else {
|
||||
return 'atom'
|
||||
return 'atom';
|
||||
}
|
||||
}
|
||||
|
||||
function computeAppVersion (version) {
|
||||
function computeAppVersion(version) {
|
||||
if (version.match(/-dev$/)) {
|
||||
const result = spawnSync('git', ['rev-parse', '--short', 'HEAD'], {
|
||||
cwd: repositoryRootPath
|
||||
|
|
|
@ -46,8 +46,11 @@ module.exports = packagedAppPath => {
|
|||
fs.renameSync(releasesPath, `${releasesPath}-x64`);
|
||||
}
|
||||
|
||||
let appName = CONFIG.channel === 'stable' ? 'atom' : `atom-${CONFIG.channel}`
|
||||
for (let nupkgPath of glob.sync(`${CONFIG.buildOutputPath}/${appName}-*.nupkg`)) {
|
||||
let appName =
|
||||
CONFIG.channel === 'stable' ? 'atom' : `atom-${CONFIG.channel}`;
|
||||
for (let nupkgPath of glob.sync(
|
||||
`${CONFIG.buildOutputPath}/${appName}-*.nupkg`
|
||||
)) {
|
||||
if (!nupkgPath.includes(CONFIG.computedAppVersion)) {
|
||||
console.log(
|
||||
`Deleting downloaded nupkg for previous version at ${nupkgPath} to prevent it from being stored as an artifact`
|
||||
|
@ -56,8 +59,11 @@ module.exports = packagedAppPath => {
|
|||
} else {
|
||||
if (process.arch === 'x64') {
|
||||
// Use the original .nupkg filename to generate the `atom-x64` name by inserting `-x64` after `atom`
|
||||
const newNupkgPath = nupkgPath.replace(`${appName}-`, `${appName}-x64-`)
|
||||
fs.renameSync(nupkgPath, newNupkgPath)
|
||||
const newNupkgPath = nupkgPath.replace(
|
||||
`${appName}-`,
|
||||
`${appName}-x64-`
|
||||
);
|
||||
fs.renameSync(nupkgPath, newNupkgPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,33 +1,41 @@
|
|||
'use strict'
|
||||
'use strict';
|
||||
|
||||
const CSON = require('season')
|
||||
const deprecatedPackagesMetadata = require('../deprecated-packages')
|
||||
const fs = require('fs-plus')
|
||||
const normalizePackageData = require('normalize-package-data')
|
||||
const path = require('path')
|
||||
const semver = require('semver')
|
||||
const CSON = require('season');
|
||||
const deprecatedPackagesMetadata = require('../deprecated-packages');
|
||||
const fs = require('fs-plus');
|
||||
const normalizePackageData = require('normalize-package-data');
|
||||
const path = require('path');
|
||||
const semver = require('semver');
|
||||
|
||||
const CONFIG = require('../config')
|
||||
const CONFIG = require('../config');
|
||||
|
||||
let appName = CONFIG.appMetadata.name
|
||||
let appName = CONFIG.appMetadata.name;
|
||||
if (process.platform === 'win32') {
|
||||
// Use the channel name in the app name on Windows so that the installer will
|
||||
// place it in a different folder in AppData\Local
|
||||
appName = CONFIG.channel === 'stable' ? 'atom' : `atom-${CONFIG.channel}`
|
||||
appName = CONFIG.channel === 'stable' ? 'atom' : `atom-${CONFIG.channel}`;
|
||||
}
|
||||
|
||||
module.exports = function () {
|
||||
console.log(`Generating metadata for ${path.join(CONFIG.intermediateAppPath, 'package.json')}`)
|
||||
CONFIG.appMetadata._atomPackages = buildBundledPackagesMetadata()
|
||||
CONFIG.appMetadata._atomMenu = buildPlatformMenuMetadata()
|
||||
CONFIG.appMetadata._atomKeymaps = buildPlatformKeymapsMetadata()
|
||||
CONFIG.appMetadata._deprecatedPackages = deprecatedPackagesMetadata
|
||||
CONFIG.appMetadata.version = CONFIG.computedAppVersion
|
||||
CONFIG.appMetadata.name = appName
|
||||
CONFIG.appMetadata.productName = CONFIG.appName
|
||||
checkDeprecatedPackagesMetadata()
|
||||
fs.writeFileSync(path.join(CONFIG.intermediateAppPath, 'package.json'), JSON.stringify(CONFIG.appMetadata))
|
||||
}
|
||||
module.exports = function() {
|
||||
console.log(
|
||||
`Generating metadata for ${path.join(
|
||||
CONFIG.intermediateAppPath,
|
||||
'package.json'
|
||||
)}`
|
||||
);
|
||||
CONFIG.appMetadata._atomPackages = buildBundledPackagesMetadata();
|
||||
CONFIG.appMetadata._atomMenu = buildPlatformMenuMetadata();
|
||||
CONFIG.appMetadata._atomKeymaps = buildPlatformKeymapsMetadata();
|
||||
CONFIG.appMetadata._deprecatedPackages = deprecatedPackagesMetadata;
|
||||
CONFIG.appMetadata.version = CONFIG.computedAppVersion;
|
||||
CONFIG.appMetadata.name = appName;
|
||||
CONFIG.appMetadata.productName = CONFIG.appName;
|
||||
checkDeprecatedPackagesMetadata();
|
||||
fs.writeFileSync(
|
||||
path.join(CONFIG.intermediateAppPath, 'package.json'),
|
||||
JSON.stringify(CONFIG.appMetadata)
|
||||
);
|
||||
};
|
||||
|
||||
module.exports = function() {
|
||||
console.log(
|
||||
|
|
|
@ -258,9 +258,17 @@ module.exports = function(packagedAppPath) {
|
|||
);
|
||||
let nodeBundledInElectronPath;
|
||||
if (process.platform === 'darwin') {
|
||||
nodeBundledInElectronPath = path.join(packagedAppPath, 'Contents', 'MacOS', CONFIG.executableName)
|
||||
nodeBundledInElectronPath = path.join(
|
||||
packagedAppPath,
|
||||
'Contents',
|
||||
'MacOS',
|
||||
CONFIG.executableName
|
||||
);
|
||||
} else {
|
||||
nodeBundledInElectronPath = path.join(packagedAppPath, CONFIG.executableName)
|
||||
nodeBundledInElectronPath = path.join(
|
||||
packagedAppPath,
|
||||
CONFIG.executableName
|
||||
);
|
||||
}
|
||||
childProcess.execFileSync(
|
||||
nodeBundledInElectronPath,
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
'use strict';
|
||||
|
||||
const assert = require('assert')
|
||||
const childProcess = require('child_process')
|
||||
const electronPackager = require('electron-packager')
|
||||
const fs = require('fs-extra')
|
||||
const hostArch = require('electron-packager/targets').hostArch
|
||||
const includePathInPackagedApp = require('./include-path-in-packaged-app')
|
||||
const getLicenseText = require('./get-license-text')
|
||||
const path = require('path')
|
||||
const spawnSync = require('./spawn-sync')
|
||||
const template = require('lodash.template')
|
||||
const assert = require('assert');
|
||||
const childProcess = require('child_process');
|
||||
const electronPackager = require('electron-packager');
|
||||
const fs = require('fs-extra');
|
||||
const hostArch = require('electron-packager/targets').hostArch;
|
||||
const includePathInPackagedApp = require('./include-path-in-packaged-app');
|
||||
const getLicenseText = require('./get-license-text');
|
||||
const path = require('path');
|
||||
const spawnSync = require('./spawn-sync');
|
||||
const template = require('lodash.template');
|
||||
|
||||
const CONFIG = require('../config');
|
||||
const HOST_ARCH = hostArch();
|
||||
|
@ -131,11 +131,22 @@ function copyNonASARResources(packagedAppPath, bundledResourcesPath) {
|
|||
path.join(packagedAppPath, 'atom.png')
|
||||
);
|
||||
} else if (process.platform === 'win32') {
|
||||
[ 'atom.sh', 'atom.js', 'apm.cmd', 'apm.sh', 'file.ico', 'folder.ico' ]
|
||||
.forEach(file => fs.copySync(path.join('resources', 'win', file), path.join(bundledResourcesPath, 'cli', file)))
|
||||
[
|
||||
'atom.sh',
|
||||
'atom.js',
|
||||
'apm.cmd',
|
||||
'apm.sh',
|
||||
'file.ico',
|
||||
'folder.ico'
|
||||
].forEach(file =>
|
||||
fs.copySync(
|
||||
path.join('resources', 'win', file),
|
||||
path.join(bundledResourcesPath, 'cli', file)
|
||||
)
|
||||
);
|
||||
|
||||
// Customize atom.cmd for the channel-specific atom.exe name (e.g. atom-beta.exe)
|
||||
generateAtomCmdForChannel(bundledResourcesPath)
|
||||
generateAtomCmdForChannel(bundledResourcesPath);
|
||||
}
|
||||
|
||||
console.log(`Writing LICENSE.md to ${bundledResourcesPath}`);
|
||||
|
@ -194,9 +205,9 @@ function buildAsarUnpackGlobExpression() {
|
|||
|
||||
function getAppName() {
|
||||
if (process.platform === 'darwin') {
|
||||
return CONFIG.appName
|
||||
return CONFIG.appName;
|
||||
} else if (process.platform === 'win32') {
|
||||
return CONFIG.channel === 'stable' ? 'atom' : `atom-${CONFIG.channel}`
|
||||
return CONFIG.channel === 'stable' ? 'atom' : `atom-${CONFIG.channel}`;
|
||||
} else {
|
||||
return 'atom';
|
||||
}
|
||||
|
@ -251,8 +262,15 @@ function renamePackagedAppDir(packageOutputDirPath) {
|
|||
return packagedAppPath;
|
||||
}
|
||||
|
||||
function generateAtomCmdForChannel (bundledResourcesPath) {
|
||||
const atomCmdTemplate = fs.readFileSync(path.join(CONFIG.repositoryRootPath, 'resources', 'win', 'atom.cmd'))
|
||||
const atomCmdContents = template(atomCmdTemplate)({ atomExeName: CONFIG.executableName })
|
||||
fs.writeFileSync(path.join(bundledResourcesPath, 'cli', 'atom.cmd'), atomCmdContents)
|
||||
function generateAtomCmdForChannel(bundledResourcesPath) {
|
||||
const atomCmdTemplate = fs.readFileSync(
|
||||
path.join(CONFIG.repositoryRootPath, 'resources', 'win', 'atom.cmd')
|
||||
);
|
||||
const atomCmdContents = template(atomCmdTemplate)({
|
||||
atomExeName: CONFIG.executableName
|
||||
});
|
||||
fs.writeFileSync(
|
||||
path.join(bundledResourcesPath, 'cli', 'atom.cmd'),
|
||||
atomCmdContents
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
const {EventEmitter} = require('events');
|
||||
const { EventEmitter } = require('events');
|
||||
const fs = require('fs-plus');
|
||||
const path = require('path');
|
||||
const temp = require('temp').track();
|
||||
|
@ -10,7 +10,7 @@ const WinShell = require('../src/main-process/win-shell');
|
|||
const invokeCallback = function(callback) {
|
||||
const error = null;
|
||||
const stdout = '';
|
||||
return (typeof callback === 'function' ? callback(error, stdout) : undefined);
|
||||
return typeof callback === 'function' ? callback(error, stdout) : undefined;
|
||||
};
|
||||
|
||||
const createFakeApp = function() {
|
||||
|
@ -19,11 +19,11 @@ const createFakeApp = function() {
|
|||
getName: () => AtomTestAppName,
|
||||
getPath: () => 'atom-test.exe'
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
const AtomTestAppName = 'Atom Testing'
|
||||
const AtomTestAppName = 'Atom Testing';
|
||||
|
||||
describe("Windows Squirrel Update", function() {
|
||||
describe('Windows Squirrel Update', function() {
|
||||
let tempHomeDirectory = null;
|
||||
|
||||
beforeEach(function() {
|
||||
|
@ -38,9 +38,15 @@ describe("Windows Squirrel Update", function() {
|
|||
);
|
||||
|
||||
// Prevent any actual change to Windows Shell
|
||||
spyOn(WinShell, 'registerShellIntegration').andCallFake((appName, callback) => callback())
|
||||
spyOn(WinShell, 'updateShellIntegration').andCallFake((appName, callback) => callback())
|
||||
spyOn(WinShell, 'deregisterShellIntegration').andCallFake((appName, callback) => callback())
|
||||
spyOn(WinShell, 'registerShellIntegration').andCallFake(
|
||||
(appName, callback) => callback()
|
||||
);
|
||||
spyOn(WinShell, 'updateShellIntegration').andCallFake((appName, callback) =>
|
||||
callback()
|
||||
);
|
||||
spyOn(WinShell, 'deregisterShellIntegration').andCallFake(
|
||||
(appName, callback) => callback()
|
||||
);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
|
@ -49,96 +55,120 @@ describe("Windows Squirrel Update", function() {
|
|||
} catch (error) {}
|
||||
});
|
||||
|
||||
it("quits the app on all squirrel events", function() {
|
||||
const app = createFakeApp()
|
||||
it('quits the app on all squirrel events', function() {
|
||||
const app = createFakeApp();
|
||||
|
||||
expect(SquirrelUpdate.handleStartupEvent(app, '--squirrel-install')).toBe(true);
|
||||
expect(SquirrelUpdate.handleStartupEvent(app, '--squirrel-install')).toBe(
|
||||
true
|
||||
);
|
||||
|
||||
waitsFor(() => app.quit.callCount === 1);
|
||||
|
||||
runs(function() {
|
||||
app.quit.reset();
|
||||
return expect(SquirrelUpdate.handleStartupEvent(app, '--squirrel-updated')).toBe(true);
|
||||
return expect(
|
||||
SquirrelUpdate.handleStartupEvent(app, '--squirrel-updated')
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
waitsFor(() => app.quit.callCount === 1);
|
||||
|
||||
runs(function() {
|
||||
app.quit.reset();
|
||||
return expect(SquirrelUpdate.handleStartupEvent(app, '--squirrel-uninstall')).toBe(true);
|
||||
return expect(
|
||||
SquirrelUpdate.handleStartupEvent(app, '--squirrel-uninstall')
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
waitsFor(() => app.quit.callCount === 1);
|
||||
|
||||
runs(function() {
|
||||
app.quit.reset();
|
||||
return expect(SquirrelUpdate.handleStartupEvent(app, '--squirrel-obsolete')).toBe(true);
|
||||
return expect(
|
||||
SquirrelUpdate.handleStartupEvent(app, '--squirrel-obsolete')
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
waitsFor(() => app.quit.callCount === 1);
|
||||
|
||||
return runs(() => expect(SquirrelUpdate.handleStartupEvent(app, '--not-squirrel')).toBe(false));
|
||||
return runs(() =>
|
||||
expect(SquirrelUpdate.handleStartupEvent(app, '--not-squirrel')).toBe(
|
||||
false
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
describe("Desktop shortcut", function() {
|
||||
describe('Desktop shortcut', function() {
|
||||
let desktopShortcutPath = '/non/existing/path';
|
||||
|
||||
beforeEach(function() {
|
||||
desktopShortcutPath = path.join(tempHomeDirectory, 'Desktop', 'Atom.lnk');
|
||||
|
||||
jasmine.unspy(Spawner, 'spawn');
|
||||
return spyOn(Spawner, 'spawn').andCallFake(function(command, args, callback) {
|
||||
if ((path.basename(command) === 'Update.exe') && ((args != null ? args[0] : undefined) === '--createShortcut') && (args != null ? args[3].match(/Desktop/i) : undefined)) {
|
||||
return spyOn(Spawner, 'spawn').andCallFake(function(
|
||||
command,
|
||||
args,
|
||||
callback
|
||||
) {
|
||||
if (
|
||||
path.basename(command) === 'Update.exe' &&
|
||||
(args != null ? args[0] : undefined) === '--createShortcut' &&
|
||||
(args != null ? args[3].match(/Desktop/i) : undefined)
|
||||
) {
|
||||
fs.writeFileSync(desktopShortcutPath, '');
|
||||
} else {
|
||||
}
|
||||
else {}
|
||||
// simply ignore other commands
|
||||
// simply ignore other commands
|
||||
|
||||
return invokeCallback(callback);
|
||||
});
|
||||
});
|
||||
|
||||
it("does not exist before install", () => expect(fs.existsSync(desktopShortcutPath)).toBe(false));
|
||||
it('does not exist before install', () =>
|
||||
expect(fs.existsSync(desktopShortcutPath)).toBe(false));
|
||||
|
||||
return describe("on install", function() {
|
||||
return describe('on install', function() {
|
||||
beforeEach(function() {
|
||||
const app = createFakeApp()
|
||||
const app = createFakeApp();
|
||||
SquirrelUpdate.handleStartupEvent(app, '--squirrel-install');
|
||||
return waitsFor(() => app.quit.callCount === 1);
|
||||
});
|
||||
|
||||
it("creates desktop shortcut", () => expect(fs.existsSync(desktopShortcutPath)).toBe(true));
|
||||
it('creates desktop shortcut', () =>
|
||||
expect(fs.existsSync(desktopShortcutPath)).toBe(true));
|
||||
|
||||
describe("when shortcut is deleted and then app is updated", function() {
|
||||
describe('when shortcut is deleted and then app is updated', function() {
|
||||
beforeEach(function() {
|
||||
fs.removeSync(desktopShortcutPath);
|
||||
expect(fs.existsSync(desktopShortcutPath)).toBe(false);
|
||||
|
||||
const app = createFakeApp()
|
||||
const app = createFakeApp();
|
||||
SquirrelUpdate.handleStartupEvent(app, '--squirrel-updated');
|
||||
return waitsFor(() => app.quit.callCount === 1);
|
||||
});
|
||||
|
||||
return it("does not recreate shortcut", () => expect(fs.existsSync(desktopShortcutPath)).toBe(false));
|
||||
return it('does not recreate shortcut', () =>
|
||||
expect(fs.existsSync(desktopShortcutPath)).toBe(false));
|
||||
});
|
||||
|
||||
return describe("when shortcut is kept and app is updated", function() {
|
||||
return describe('when shortcut is kept and app is updated', function() {
|
||||
beforeEach(function() {
|
||||
const app = createFakeApp()
|
||||
const app = createFakeApp();
|
||||
SquirrelUpdate.handleStartupEvent(app, '--squirrel-updated');
|
||||
return waitsFor(() => app.quit.callCount === 1);
|
||||
});
|
||||
|
||||
return it("still has desktop shortcut", () => expect(fs.existsSync(desktopShortcutPath)).toBe(true));
|
||||
return it('still has desktop shortcut', () =>
|
||||
expect(fs.existsSync(desktopShortcutPath)).toBe(true));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
return describe(".restartAtom", () =>
|
||||
it("quits the app and spawns a new one", function() {
|
||||
return describe('.restartAtom', () =>
|
||||
it('quits the app and spawns a new one', function() {
|
||||
const app = new EventEmitter();
|
||||
app.quit = jasmine.createSpy('quit');
|
||||
app.getPath = () => 'atom-test.exe'
|
||||
app.getPath = () => 'atom-test.exe';
|
||||
|
||||
SquirrelUpdate.restartAtom(app);
|
||||
expect(app.quit.callCount).toBe(1);
|
||||
|
@ -146,7 +176,8 @@ describe("Windows Squirrel Update", function() {
|
|||
expect(Spawner.spawn.callCount).toBe(0);
|
||||
app.emit('will-quit');
|
||||
expect(Spawner.spawn.callCount).toBe(1);
|
||||
return expect(path.basename(Spawner.spawn.argsForCall[0][0])).toBe('atom-test.cmd');
|
||||
})
|
||||
);
|
||||
return expect(path.basename(Spawner.spawn.argsForCall[0][0])).toBe(
|
||||
'atom-test.cmd'
|
||||
);
|
||||
}));
|
||||
});
|
||||
|
|
|
@ -551,9 +551,9 @@ class AtomEnvironment {
|
|||
// Public: Get the full name of this Atom release (e.g. "Atom", "Atom Beta")
|
||||
//
|
||||
// Returns the app name {String}.
|
||||
getAppName () {
|
||||
if (this.appName == null) this.appName = this.getLoadSettings().appName
|
||||
return this.appName
|
||||
getAppName() {
|
||||
if (this.appName == null) this.appName = this.getLoadSettings().appName;
|
||||
return this.appName;
|
||||
}
|
||||
|
||||
// Public: Get the version of the Atom application.
|
||||
|
|
|
@ -63,31 +63,39 @@ module.exports = class AtomWindow extends EventEmitter {
|
|||
this.browserWindow = new BrowserWindowConstructor(options);
|
||||
|
||||
Object.defineProperty(this.browserWindow, 'loadSettingsJSON', {
|
||||
get: () => JSON.stringify(Object.assign({
|
||||
userSettings: !this.isSpec
|
||||
? this.atomApplication.configFile.get()
|
||||
: null
|
||||
}, this.loadSettings))
|
||||
})
|
||||
get: () =>
|
||||
JSON.stringify(
|
||||
Object.assign(
|
||||
{
|
||||
userSettings: !this.isSpec
|
||||
? this.atomApplication.configFile.get()
|
||||
: null
|
||||
},
|
||||
this.loadSettings
|
||||
)
|
||||
)
|
||||
});
|
||||
|
||||
this.handleEvents()
|
||||
this.handleEvents();
|
||||
|
||||
this.loadSettings = Object.assign({}, settings)
|
||||
this.loadSettings.appVersion = app.getVersion()
|
||||
this.loadSettings.appName = app.getName()
|
||||
this.loadSettings.resourcePath = this.resourcePath
|
||||
this.loadSettings.atomHome = process.env.ATOM_HOME
|
||||
if (this.loadSettings.devMode == null) this.loadSettings.devMode = false
|
||||
if (this.loadSettings.safeMode == null) this.loadSettings.safeMode = false
|
||||
if (this.loadSettings.clearWindowState == null) this.loadSettings.clearWindowState = false
|
||||
this.loadSettings = Object.assign({}, settings);
|
||||
this.loadSettings.appVersion = app.getVersion();
|
||||
this.loadSettings.appName = app.getName();
|
||||
this.loadSettings.resourcePath = this.resourcePath;
|
||||
this.loadSettings.atomHome = process.env.ATOM_HOME;
|
||||
if (this.loadSettings.devMode == null) this.loadSettings.devMode = false;
|
||||
if (this.loadSettings.safeMode == null) this.loadSettings.safeMode = false;
|
||||
if (this.loadSettings.clearWindowState == null)
|
||||
this.loadSettings.clearWindowState = false;
|
||||
|
||||
this.addLocationsToOpen(locationsToOpen)
|
||||
this.addLocationsToOpen(locationsToOpen);
|
||||
|
||||
this.loadSettings.hasOpenFiles = locationsToOpen
|
||||
.some(location => location.pathToOpen && !location.isDirectory)
|
||||
this.loadSettings.initialProjectRoots = this.projectRoots
|
||||
this.loadSettings.hasOpenFiles = locationsToOpen.some(
|
||||
location => location.pathToOpen && !location.isDirectory
|
||||
);
|
||||
this.loadSettings.initialProjectRoots = this.projectRoots;
|
||||
|
||||
StartupTime.addMarker('main-process:atom-window:end')
|
||||
StartupTime.addMarker('main-process:atom-window:end');
|
||||
|
||||
// Expose the startup markers to the renderer process, so we can have unified
|
||||
// measures about startup time between the main process and the renderer process.
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
let setxPath
|
||||
const fs = require('fs-plus')
|
||||
const path = require('path')
|
||||
const Spawner = require('./spawner')
|
||||
const WinShell = require('./win-shell')
|
||||
const WinPowerShell = require('./win-powershell')
|
||||
let setxPath;
|
||||
const fs = require('fs-plus');
|
||||
const path = require('path');
|
||||
const Spawner = require('./spawner');
|
||||
const WinShell = require('./win-shell');
|
||||
const WinPowerShell = require('./win-powershell');
|
||||
|
||||
const appFolder = path.resolve(process.execPath, '..')
|
||||
const rootAtomFolder = path.resolve(appFolder, '..')
|
||||
const binFolder = path.join(rootAtomFolder, 'bin')
|
||||
const updateDotExe = path.join(rootAtomFolder, 'Update.exe')
|
||||
const appFolder = path.resolve(process.execPath, '..');
|
||||
const rootAtomFolder = path.resolve(appFolder, '..');
|
||||
const binFolder = path.join(rootAtomFolder, 'bin');
|
||||
const updateDotExe = path.join(rootAtomFolder, 'Update.exe');
|
||||
|
||||
if (process.env.SystemRoot) {
|
||||
const system32Path = path.join(process.env.SystemRoot, 'System32');
|
||||
|
@ -31,25 +31,43 @@ const spawnUpdate = (args, callback) =>
|
|||
// install directory that point to the newly installed versions inside
|
||||
// the versioned app directories.
|
||||
const addCommandsToPath = (exeName, callback) => {
|
||||
const atomCmdName = exeName.replace('.exe', '.cmd')
|
||||
const apmCmdName = atomCmdName.replace('atom', 'apm')
|
||||
const atomCmdName = exeName.replace('.exe', '.cmd');
|
||||
const apmCmdName = atomCmdName.replace('atom', 'apm');
|
||||
|
||||
const installCommands = callback => {
|
||||
const atomCommandPath = path.join(binFolder, atomCmdName)
|
||||
const relativeAtomPath = path.relative(binFolder, path.join(appFolder, 'resources', 'cli', 'atom.cmd'))
|
||||
const atomCommand = `@echo off\r\n"%~dp0\\${relativeAtomPath}" %*`
|
||||
const atomCommandPath = path.join(binFolder, atomCmdName);
|
||||
const relativeAtomPath = path.relative(
|
||||
binFolder,
|
||||
path.join(appFolder, 'resources', 'cli', 'atom.cmd')
|
||||
);
|
||||
const atomCommand = `@echo off\r\n"%~dp0\\${relativeAtomPath}" %*`;
|
||||
|
||||
const atomShCommandPath = path.join(binFolder, 'atom')
|
||||
const relativeAtomShPath = path.relative(binFolder, path.join(appFolder, 'resources', 'cli', 'atom.sh'))
|
||||
const atomShCommand = `#!/bin/sh\r\n"$(dirname "$0")/${relativeAtomShPath.replace(/\\/g, '/')}" "$@"\r\necho`
|
||||
const atomShCommandPath = path.join(binFolder, 'atom');
|
||||
const relativeAtomShPath = path.relative(
|
||||
binFolder,
|
||||
path.join(appFolder, 'resources', 'cli', 'atom.sh')
|
||||
);
|
||||
const atomShCommand = `#!/bin/sh\r\n"$(dirname "$0")/${relativeAtomShPath.replace(
|
||||
/\\/g,
|
||||
'/'
|
||||
)}" "$@"\r\necho`;
|
||||
|
||||
const apmCommandPath = path.join(binFolder, apmCmdName)
|
||||
const relativeApmPath = path.relative(binFolder, path.join(process.resourcesPath, 'app', 'apm', 'bin', 'apm.cmd'))
|
||||
const apmCommand = `@echo off\r\n"%~dp0\\${relativeApmPath}" %*`
|
||||
const apmCommandPath = path.join(binFolder, apmCmdName);
|
||||
const relativeApmPath = path.relative(
|
||||
binFolder,
|
||||
path.join(process.resourcesPath, 'app', 'apm', 'bin', 'apm.cmd')
|
||||
);
|
||||
const apmCommand = `@echo off\r\n"%~dp0\\${relativeApmPath}" %*`;
|
||||
|
||||
const apmShCommandPath = path.join(binFolder, 'apm')
|
||||
const relativeApmShPath = path.relative(binFolder, path.join(appFolder, 'resources', 'cli', 'apm.sh'))
|
||||
const apmShCommand = `#!/bin/sh\r\n"$(dirname "$0")/${relativeApmShPath.replace(/\\/g, '/')}" "$@"`
|
||||
const apmShCommandPath = path.join(binFolder, 'apm');
|
||||
const relativeApmShPath = path.relative(
|
||||
binFolder,
|
||||
path.join(appFolder, 'resources', 'cli', 'apm.sh')
|
||||
);
|
||||
const apmShCommand = `#!/bin/sh\r\n"$(dirname "$0")/${relativeApmShPath.replace(
|
||||
/\\/g,
|
||||
'/'
|
||||
)}" "$@"`;
|
||||
|
||||
fs.writeFile(atomCommandPath, atomCommand, () =>
|
||||
fs.writeFile(atomShCommandPath, atomShCommand, () =>
|
||||
|
@ -103,19 +121,26 @@ const removeCommandsFromPath = callback =>
|
|||
}
|
||||
});
|
||||
|
||||
const getExeName = (app) => path.basename(app.getPath('exe'))
|
||||
const getExeName = app => path.basename(app.getPath('exe'));
|
||||
|
||||
// Create a desktop and start menu shortcut by using the command line API
|
||||
// provided by Squirrel's Update.exe
|
||||
const createShortcuts = (exeName, locations, callback) =>
|
||||
spawnUpdate(['--createShortcut', exeName, '-l', locations.join(',')], callback)
|
||||
spawnUpdate(
|
||||
['--createShortcut', exeName, '-l', locations.join(',')],
|
||||
callback
|
||||
);
|
||||
|
||||
// Update the desktop and start menu shortcuts by using the command line API
|
||||
// provided by Squirrel's Update.exe
|
||||
const updateShortcuts = (appName, exeName, callback) => {
|
||||
const homeDirectory = fs.getHomeDirectory()
|
||||
const homeDirectory = fs.getHomeDirectory();
|
||||
if (homeDirectory) {
|
||||
const desktopShortcutPath = path.join(homeDirectory, 'Desktop', `${appName}.lnk`)
|
||||
const desktopShortcutPath = path.join(
|
||||
homeDirectory,
|
||||
'Desktop',
|
||||
`${appName}.lnk`
|
||||
);
|
||||
// Check if the desktop shortcut has been previously deleted and
|
||||
// and keep it deleted if it was
|
||||
fs.exists(desktopShortcutPath, desktopShortcutExists => {
|
||||
|
@ -124,16 +149,17 @@ const updateShortcuts = (appName, exeName, callback) => {
|
|||
locations.push('Desktop');
|
||||
}
|
||||
|
||||
createShortcuts(exeName, locations, callback)
|
||||
})
|
||||
createShortcuts(exeName, locations, callback);
|
||||
});
|
||||
} else {
|
||||
createShortcuts(exeName, ['Desktop', 'StartMenu'], callback)
|
||||
createShortcuts(exeName, ['Desktop', 'StartMenu'], callback);
|
||||
}
|
||||
};
|
||||
|
||||
// Remove the desktop and start menu shortcuts by using the command line API
|
||||
// provided by Squirrel's Update.exe
|
||||
const removeShortcuts = (exeName, callback) => spawnUpdate(['--removeShortcut', exeName], callback)
|
||||
const removeShortcuts = (exeName, callback) =>
|
||||
spawnUpdate(['--removeShortcut', exeName], callback);
|
||||
|
||||
exports.spawn = spawnUpdate;
|
||||
|
||||
|
@ -141,21 +167,23 @@ exports.spawn = spawnUpdate;
|
|||
exports.existsSync = () => fs.existsSync(updateDotExe);
|
||||
|
||||
// Restart Atom using the version pointed to by the atom.cmd shim
|
||||
exports.restartAtom = (app) => {
|
||||
let args
|
||||
const exeName = getExeName(app)
|
||||
const atomCmdName = exeName.replace('.exe', '.cmd')
|
||||
exports.restartAtom = app => {
|
||||
let args;
|
||||
const exeName = getExeName(app);
|
||||
const atomCmdName = exeName.replace('.exe', '.cmd');
|
||||
if (global.atomApplication && global.atomApplication.lastFocusedWindow) {
|
||||
const { projectPath } = global.atomApplication.lastFocusedWindow;
|
||||
if (projectPath) args = [projectPath];
|
||||
}
|
||||
app.once('will-quit', () => Spawner.spawn(path.join(binFolder, atomCmdName), args))
|
||||
app.quit()
|
||||
}
|
||||
app.once('will-quit', () =>
|
||||
Spawner.spawn(path.join(binFolder, atomCmdName), args)
|
||||
);
|
||||
app.quit();
|
||||
};
|
||||
|
||||
// Handle squirrel events denoted by --squirrel-* command line arguments.
|
||||
exports.handleStartupEvent = (app, squirrelCommand) => {
|
||||
const exeName = getExeName(app)
|
||||
const exeName = getExeName(app);
|
||||
switch (squirrelCommand) {
|
||||
case '--squirrel-install':
|
||||
createShortcuts(exeName, ['Desktop', 'StartMenu'], () =>
|
||||
|
|
|
@ -1,9 +1,15 @@
|
|||
const Registry = require('winreg');
|
||||
const Path = require('path');
|
||||
|
||||
let exeName = Path.basename(process.execPath)
|
||||
let appPath = `"${process.execPath}"`
|
||||
let fileIconPath = `"${Path.join(process.execPath, '..', 'resources', 'cli', 'file.ico')}"`
|
||||
let exeName = Path.basename(process.execPath);
|
||||
let appPath = `"${process.execPath}"`;
|
||||
let fileIconPath = `"${Path.join(
|
||||
process.execPath,
|
||||
'..',
|
||||
'resources',
|
||||
'cli',
|
||||
'file.ico'
|
||||
)}"`;
|
||||
|
||||
class ShellOption {
|
||||
constructor(key, parts) {
|
||||
|
@ -65,64 +71,72 @@ class ShellOption {
|
|||
}
|
||||
}
|
||||
|
||||
function getShellOptions (appName) {
|
||||
function getShellOptions(appName) {
|
||||
const contextParts = [
|
||||
{key: 'command', name: '', value: `${appPath} "%1"`},
|
||||
{name: '', value: `Open with ${appName}`},
|
||||
{name: 'Icon', value: `${appPath}`}
|
||||
]
|
||||
{ key: 'command', name: '', value: `${appPath} "%1"` },
|
||||
{ name: '', value: `Open with ${appName}` },
|
||||
{ name: 'Icon', value: `${appPath}` }
|
||||
];
|
||||
|
||||
return {
|
||||
fileHandler: new ShellOption(`\\Software\\Classes\\Applications\\${exeName}`,
|
||||
fileHandler: new ShellOption(
|
||||
`\\Software\\Classes\\Applications\\${exeName}`,
|
||||
[
|
||||
{key: 'shell\\open\\command', name: '', value: `${appPath} "%1"`},
|
||||
{key: 'shell\\open', name: 'FriendlyAppName', value: `${appName}`},
|
||||
{key: 'DefaultIcon', name: '', value: `${fileIconPath}`}
|
||||
{ key: 'shell\\open\\command', name: '', value: `${appPath} "%1"` },
|
||||
{ key: 'shell\\open', name: 'FriendlyAppName', value: `${appName}` },
|
||||
{ key: 'DefaultIcon', name: '', value: `${fileIconPath}` }
|
||||
]
|
||||
),
|
||||
fileContextMenu: new ShellOption(`\\Software\\Classes\\*\\shell\\${appName}`, contextParts),
|
||||
folderContextMenu: new ShellOption(`\\Software\\Classes\\Directory\\shell\\${appName}`, contextParts),
|
||||
folderBackgroundContextMenu: new ShellOption(`\\Software\\Classes\\Directory\\background\\shell\\${appName}`,
|
||||
fileContextMenu: new ShellOption(
|
||||
`\\Software\\Classes\\*\\shell\\${appName}`,
|
||||
contextParts
|
||||
),
|
||||
folderContextMenu: new ShellOption(
|
||||
`\\Software\\Classes\\Directory\\shell\\${appName}`,
|
||||
contextParts
|
||||
),
|
||||
folderBackgroundContextMenu: new ShellOption(
|
||||
`\\Software\\Classes\\Directory\\background\\shell\\${appName}`,
|
||||
JSON.parse(JSON.stringify(contextParts).replace('%1', '%V'))
|
||||
)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function registerShellIntegration (appName, callback) {
|
||||
const shellOptions = getShellOptions(appName)
|
||||
function registerShellIntegration(appName, callback) {
|
||||
const shellOptions = getShellOptions(appName);
|
||||
shellOptions.fileHandler.register(() =>
|
||||
shellOptions.fileContextMenu.update(() =>
|
||||
shellOptions.folderContextMenu.update(() =>
|
||||
shellOptions.folderBackgroundContextMenu.update(() => callback())
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function updateShellIntegration (appName, callback) {
|
||||
const shellOptions = getShellOptions(appName)
|
||||
function updateShellIntegration(appName, callback) {
|
||||
const shellOptions = getShellOptions(appName);
|
||||
shellOptions.fileHandler.update(() =>
|
||||
shellOptions.fileContextMenu.update(() =>
|
||||
shellOptions.folderContextMenu.update(() =>
|
||||
shellOptions.folderBackgroundContextMenu.update(() => callback())
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function deregisterShellIntegration (appName, callback) {
|
||||
const shellOptions = getShellOptions(appName)
|
||||
function deregisterShellIntegration(appName, callback) {
|
||||
const shellOptions = getShellOptions(appName);
|
||||
shellOptions.fileHandler.deregister(() =>
|
||||
shellOptions.fileContextMenu.deregister(() =>
|
||||
shellOptions.folderContextMenu.deregister(() =>
|
||||
shellOptions.folderBackgroundContextMenu.deregister(() => callback())
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
registerShellIntegration,
|
||||
updateShellIntegration,
|
||||
deregisterShellIntegration
|
||||
}
|
||||
};
|
||||
|
|
|
@ -678,12 +678,12 @@ module.exports = class Workspace extends Model {
|
|||
|
||||
// Updates the application's title and proxy icon based on whichever file is
|
||||
// open.
|
||||
updateWindowTitle () {
|
||||
let itemPath, itemTitle, projectPath, representedPath
|
||||
const appName = atom.getAppName()
|
||||
const left = this.project.getPaths()
|
||||
const projectPaths = left != null ? left : []
|
||||
const item = this.getActivePaneItem()
|
||||
updateWindowTitle() {
|
||||
let itemPath, itemTitle, projectPath, representedPath;
|
||||
const appName = atom.getAppName();
|
||||
const left = this.project.getPaths();
|
||||
const projectPaths = left != null ? left : [];
|
||||
const item = this.getActivePaneItem();
|
||||
if (item) {
|
||||
itemPath =
|
||||
typeof item.getPath === 'function' ? item.getPath() : undefined;
|
||||
|
|
Loading…
Reference in New Issue