diff --git a/benchmarks/benchmark-runner.js b/benchmarks/benchmark-runner.js
index 10586818d5e..c1e6e524e82 100644
--- a/benchmarks/benchmark-runner.js
+++ b/benchmarks/benchmark-runner.js
@@ -1,72 +1,75 @@
-const Chart = require('chart.js')
-const glob = require('glob')
-const fs = require('fs-plus')
-const path = require('path')
+const Chart = require('chart.js');
+const glob = require('glob');
+const fs = require('fs-plus');
+const path = require('path');
-module.exports = async ({test, benchmarkPaths}) => {
- document.body.style.backgroundColor = '#ffffff'
- document.body.style.overflow = 'auto'
+module.exports = async ({ test, benchmarkPaths }) => {
+ document.body.style.backgroundColor = '#ffffff';
+ document.body.style.overflow = 'auto';
- let paths = []
+ let paths = [];
for (const benchmarkPath of benchmarkPaths) {
if (fs.isDirectorySync(benchmarkPath)) {
- paths = paths.concat(glob.sync(path.join(benchmarkPath, '**', '*.bench.js')))
+ paths = paths.concat(
+ glob.sync(path.join(benchmarkPath, '**', '*.bench.js'))
+ );
} else {
- paths.push(benchmarkPath)
+ paths.push(benchmarkPath);
}
}
while (paths.length > 0) {
- const benchmark = require(paths.shift())({test})
- let results
+ const benchmark = require(paths.shift())({ test });
+ let results;
if (benchmark instanceof Promise) {
- results = await benchmark
+ results = await benchmark;
} else {
- results = benchmark
+ results = benchmark;
}
- const dataByBenchmarkName = {}
- for (const {name, duration, x} of results) {
- dataByBenchmarkName[name] = dataByBenchmarkName[name] || {points: []}
- dataByBenchmarkName[name].points.push({x, y: duration})
+ const dataByBenchmarkName = {};
+ for (const { name, duration, x } of results) {
+ dataByBenchmarkName[name] = dataByBenchmarkName[name] || { points: [] };
+ dataByBenchmarkName[name].points.push({ x, y: duration });
}
- const benchmarkContainer = document.createElement('div')
- document.body.appendChild(benchmarkContainer)
+ const benchmarkContainer = document.createElement('div');
+ document.body.appendChild(benchmarkContainer);
for (const key in dataByBenchmarkName) {
- const data = dataByBenchmarkName[key]
+ const data = dataByBenchmarkName[key];
if (data.points.length > 1) {
- const canvas = document.createElement('canvas')
- benchmarkContainer.appendChild(canvas)
+ const canvas = document.createElement('canvas');
+ benchmarkContainer.appendChild(canvas);
// eslint-disable-next-line no-new
new Chart(canvas, {
type: 'line',
data: {
- datasets: [{label: key, fill: false, data: data.points}]
+ datasets: [{ label: key, fill: false, data: data.points }]
},
options: {
showLines: false,
- scales: {xAxes: [{type: 'linear', position: 'bottom'}]}
+ scales: { xAxes: [{ type: 'linear', position: 'bottom' }] }
}
- })
+ });
- const textualOutput = `${key}:\n\n` + data.points.map((p) => `${p.x}\t${p.y}`).join('\n')
- console.log(textualOutput)
+ const textualOutput =
+ `${key}:\n\n` + data.points.map(p => `${p.x}\t${p.y}`).join('\n');
+ console.log(textualOutput);
} else {
- const title = document.createElement('h2')
- title.textContent = key
- benchmarkContainer.appendChild(title)
- const duration = document.createElement('p')
- duration.textContent = `${data.points[0].y}ms`
- benchmarkContainer.appendChild(duration)
+ const title = document.createElement('h2');
+ title.textContent = key;
+ benchmarkContainer.appendChild(title);
+ const duration = document.createElement('p');
+ duration.textContent = `${data.points[0].y}ms`;
+ benchmarkContainer.appendChild(duration);
- const textualOutput = `${key}: ${data.points[0].y}`
- console.log(textualOutput)
+ const textualOutput = `${key}: ${data.points[0].y}`;
+ console.log(textualOutput);
}
- await global.atom.reset()
+ await global.atom.reset();
}
}
- return 0
-}
+ return 0;
+};
diff --git a/benchmarks/text-editor-large-file-construction.bench.js b/benchmarks/text-editor-large-file-construction.bench.js
index ff564e5ca00..eba748a54f7 100644
--- a/benchmarks/text-editor-large-file-construction.bench.js
+++ b/benchmarks/text-editor-large-file-construction.bench.js
@@ -1,88 +1,100 @@
-const {TextEditor, TextBuffer} = require('atom')
+const { TextEditor, TextBuffer } = require('atom');
-const MIN_SIZE_IN_KB = 0 * 1024
-const MAX_SIZE_IN_KB = 10 * 1024
-const SIZE_STEP_IN_KB = 1024
-const LINE_TEXT = 'Lorem ipsum dolor sit amet\n'
-const TEXT = LINE_TEXT.repeat(Math.ceil(MAX_SIZE_IN_KB * 1024 / LINE_TEXT.length))
+const MIN_SIZE_IN_KB = 0 * 1024;
+const MAX_SIZE_IN_KB = 10 * 1024;
+const SIZE_STEP_IN_KB = 1024;
+const LINE_TEXT = 'Lorem ipsum dolor sit amet\n';
+const TEXT = LINE_TEXT.repeat(
+ Math.ceil((MAX_SIZE_IN_KB * 1024) / LINE_TEXT.length)
+);
-module.exports = async ({test}) => {
- const data = []
+module.exports = async ({ test }) => {
+ const data = [];
- document.body.appendChild(atom.workspace.getElement())
+ document.body.appendChild(atom.workspace.getElement());
- atom.packages.loadPackages()
- await atom.packages.activate()
+ atom.packages.loadPackages();
+ await atom.packages.activate();
for (let pane of atom.workspace.getPanes()) {
- pane.destroy()
+ pane.destroy();
}
- for (let sizeInKB = MIN_SIZE_IN_KB; sizeInKB < MAX_SIZE_IN_KB; sizeInKB += SIZE_STEP_IN_KB) {
- const text = TEXT.slice(0, sizeInKB * 1024)
- console.log(text.length / 1024)
-
- let t0 = window.performance.now()
- const buffer = new TextBuffer({text})
- const editor = new TextEditor({buffer, autoHeight: false, largeFileMode: true})
- atom.grammars.autoAssignLanguageMode(buffer)
- atom.workspace.getActivePane().activateItem(editor)
- let t1 = window.performance.now()
+ for (
+ let sizeInKB = MIN_SIZE_IN_KB;
+ sizeInKB < MAX_SIZE_IN_KB;
+ sizeInKB += SIZE_STEP_IN_KB
+ ) {
+ const text = TEXT.slice(0, sizeInKB * 1024);
+ console.log(text.length / 1024);
+
+ let t0 = window.performance.now();
+ const buffer = new TextBuffer({ text });
+ const editor = new TextEditor({
+ buffer,
+ autoHeight: false,
+ largeFileMode: true
+ });
+ atom.grammars.autoAssignLanguageMode(buffer);
+ atom.workspace.getActivePane().activateItem(editor);
+ let t1 = window.performance.now();
data.push({
name: 'Opening a large file',
x: sizeInKB,
duration: t1 - t0
- })
+ });
- const tickDurations = []
+ const tickDurations = [];
for (let i = 0; i < 20; i++) {
- await timeout(50)
- t0 = window.performance.now()
- await timeout(0)
- t1 = window.performance.now()
- tickDurations[i] = t1 - t0
+ await timeout(50);
+ t0 = window.performance.now();
+ await timeout(0);
+ t1 = window.performance.now();
+ tickDurations[i] = t1 - t0;
}
data.push({
name: 'Max time event loop was blocked after opening a large file',
x: sizeInKB,
duration: Math.max(...tickDurations)
- })
+ });
- t0 = window.performance.now()
- editor.setCursorScreenPosition(editor.element.screenPositionForPixelPosition({
- top: 100,
- left: 30
- }))
- t1 = window.performance.now()
+ t0 = window.performance.now();
+ editor.setCursorScreenPosition(
+ editor.element.screenPositionForPixelPosition({
+ top: 100,
+ left: 30
+ })
+ );
+ t1 = window.performance.now();
data.push({
name: 'Clicking the editor after opening a large file',
x: sizeInKB,
duration: t1 - t0
- })
+ });
- t0 = window.performance.now()
- editor.element.setScrollTop(editor.element.getScrollTop() + 100)
- t1 = window.performance.now()
+ t0 = window.performance.now();
+ editor.element.setScrollTop(editor.element.getScrollTop() + 100);
+ t1 = window.performance.now();
data.push({
name: 'Scrolling down after opening a large file',
x: sizeInKB,
duration: t1 - t0
- })
+ });
- editor.destroy()
- buffer.destroy()
- await timeout(10000)
+ editor.destroy();
+ buffer.destroy();
+ await timeout(10000);
}
- atom.workspace.getElement().remove()
+ atom.workspace.getElement().remove();
- return data
-}
+ return data;
+};
-function timeout (duration) {
- return new Promise((resolve) => setTimeout(resolve, duration))
+function timeout(duration) {
+ return new Promise(resolve => setTimeout(resolve, duration));
}
diff --git a/benchmarks/text-editor-long-lines.bench.js b/benchmarks/text-editor-long-lines.bench.js
index 92a9b9b9e5d..ac2f788a605 100644
--- a/benchmarks/text-editor-long-lines.bench.js
+++ b/benchmarks/text-editor-long-lines.bench.js
@@ -1,95 +1,105 @@
-const path = require('path')
-const fs = require('fs')
-const {TextEditor, TextBuffer} = require('atom')
-
-const SIZES_IN_KB = [
- 512,
- 1024,
- 2048
-]
-const REPEATED_TEXT = fs.readFileSync(path.join(__dirname, '..', 'spec', 'fixtures', 'sample.js'), 'utf8').replace(/\n/g, '')
-const TEXT = REPEATED_TEXT.repeat(Math.ceil(SIZES_IN_KB[SIZES_IN_KB.length - 1] * 1024 / REPEATED_TEXT.length))
-
-module.exports = async ({test}) => {
- const data = []
-
- const workspaceElement = atom.workspace.getElement()
- document.body.appendChild(workspaceElement)
-
- atom.packages.loadPackages()
- await atom.packages.activate()
+const path = require('path');
+const fs = require('fs');
+const { TextEditor, TextBuffer } = require('atom');
+
+const SIZES_IN_KB = [512, 1024, 2048];
+const REPEATED_TEXT = fs
+ .readFileSync(
+ path.join(__dirname, '..', 'spec', 'fixtures', 'sample.js'),
+ 'utf8'
+ )
+ .replace(/\n/g, '');
+const TEXT = REPEATED_TEXT.repeat(
+ Math.ceil((SIZES_IN_KB[SIZES_IN_KB.length - 1] * 1024) / REPEATED_TEXT.length)
+);
+
+module.exports = async ({ test }) => {
+ const data = [];
+
+ const workspaceElement = atom.workspace.getElement();
+ document.body.appendChild(workspaceElement);
+
+ atom.packages.loadPackages();
+ await atom.packages.activate();
console.log(atom.getLoadSettings().resourcePath);
for (let pane of atom.workspace.getPanes()) {
- pane.destroy()
+ pane.destroy();
}
for (const sizeInKB of SIZES_IN_KB) {
- const text = TEXT.slice(0, sizeInKB * 1024)
- console.log(text.length / 1024)
-
- let t0 = window.performance.now()
- const buffer = new TextBuffer({text})
- const editor = new TextEditor({buffer, autoHeight: false, largeFileMode: true})
- atom.grammars.assignLanguageMode(buffer, 'source.js')
- atom.workspace.getActivePane().activateItem(editor)
- let t1 = window.performance.now()
+ const text = TEXT.slice(0, sizeInKB * 1024);
+ console.log(text.length / 1024);
+
+ let t0 = window.performance.now();
+ const buffer = new TextBuffer({ text });
+ const editor = new TextEditor({
+ buffer,
+ autoHeight: false,
+ largeFileMode: true
+ });
+ atom.grammars.assignLanguageMode(buffer, 'source.js');
+ atom.workspace.getActivePane().activateItem(editor);
+ let t1 = window.performance.now();
data.push({
name: 'Opening a large single-line file',
x: sizeInKB,
duration: t1 - t0
- })
+ });
- const tickDurations = []
+ const tickDurations = [];
for (let i = 0; i < 20; i++) {
- await timeout(50)
- t0 = window.performance.now()
- await timeout(0)
- t1 = window.performance.now()
- tickDurations[i] = t1 - t0
+ await timeout(50);
+ t0 = window.performance.now();
+ await timeout(0);
+ t1 = window.performance.now();
+ tickDurations[i] = t1 - t0;
}
data.push({
- name: 'Max time event loop was blocked after opening a large single-line file',
+ name:
+ 'Max time event loop was blocked after opening a large single-line file',
x: sizeInKB,
duration: Math.max(...tickDurations)
- })
+ });
- t0 = window.performance.now()
- editor.setCursorScreenPosition(editor.element.screenPositionForPixelPosition({
- top: 100,
- left: 30
- }))
- t1 = window.performance.now()
+ t0 = window.performance.now();
+ editor.setCursorScreenPosition(
+ editor.element.screenPositionForPixelPosition({
+ top: 100,
+ left: 30
+ })
+ );
+ t1 = window.performance.now();
data.push({
name: 'Clicking the editor after opening a large single-line file',
x: sizeInKB,
duration: t1 - t0
- })
+ });
- t0 = window.performance.now()
- editor.element.setScrollTop(editor.element.getScrollTop() + 100)
- t1 = window.performance.now()
+ t0 = window.performance.now();
+ editor.element.setScrollTop(editor.element.getScrollTop() + 100);
+ t1 = window.performance.now();
data.push({
name: 'Scrolling down after opening a large single-line file',
x: sizeInKB,
duration: t1 - t0
- })
+ });
- editor.destroy()
- buffer.destroy()
- await timeout(10000)
+ editor.destroy();
+ buffer.destroy();
+ await timeout(10000);
}
- workspaceElement.remove()
+ workspaceElement.remove();
- return data
-}
+ return data;
+};
-function timeout (duration) {
- return new Promise((resolve) => setTimeout(resolve, duration))
+function timeout(duration) {
+ return new Promise(resolve => setTimeout(resolve, duration));
}
diff --git a/exports/atom.js b/exports/atom.js
index 359f0174e3b..c70d0406a24 100644
--- a/exports/atom.js
+++ b/exports/atom.js
@@ -1,12 +1,12 @@
-const TextBuffer = require('text-buffer')
-const {Point, Range} = TextBuffer
-const {File, Directory} = require('pathwatcher')
-const {Emitter, Disposable, CompositeDisposable} = require('event-kit')
-const BufferedNodeProcess = require('../src/buffered-node-process')
-const BufferedProcess = require('../src/buffered-process')
-const GitRepository = require('../src/git-repository')
-const Notification = require('../src/notification')
-const {watchPath} = require('../src/path-watcher')
+const TextBuffer = require('text-buffer');
+const { Point, Range } = TextBuffer;
+const { File, Directory } = require('pathwatcher');
+const { Emitter, Disposable, CompositeDisposable } = require('event-kit');
+const BufferedNodeProcess = require('../src/buffered-node-process');
+const BufferedProcess = require('../src/buffered-process');
+const GitRepository = require('../src/git-repository');
+const Notification = require('../src/notification');
+const { watchPath } = require('../src/path-watcher');
const atomExport = {
BufferedNodeProcess,
@@ -22,23 +22,23 @@ const atomExport = {
Disposable,
CompositeDisposable,
watchPath
-}
+};
// Shell integration is required by both Squirrel and Settings-View
if (process.platform === 'win32') {
Object.defineProperty(atomExport, 'WinShell', {
enumerable: true,
- get () {
- return require('../src/main-process/win-shell')
+ get() {
+ return require('../src/main-process/win-shell');
}
- })
+ });
}
// The following classes can't be used from a Task handler and should therefore
// only be exported when not running as a child node process
if (process.type === 'renderer') {
- atomExport.Task = require('../src/task')
- atomExport.TextEditor = require('../src/text-editor')
+ atomExport.Task = require('../src/task');
+ atomExport.TextEditor = require('../src/text-editor');
}
-module.exports = atomExport
+module.exports = atomExport;
diff --git a/exports/clipboard.js b/exports/clipboard.js
index 3594b33424f..020ce94e8da 100644
--- a/exports/clipboard.js
+++ b/exports/clipboard.js
@@ -1,7 +1,9 @@
-module.exports = require('electron').clipboard
+module.exports = require('electron').clipboard;
-const Grim = require('grim')
-Grim.deprecate('Use `require("electron").clipboard` instead of `require("clipboard")`')
+const Grim = require('grim');
+Grim.deprecate(
+ 'Use `require("electron").clipboard` instead of `require("clipboard")`'
+);
// Ensure each package that requires this shim causes a deprecation warning
-delete require.cache[__filename]
+delete require.cache[__filename];
diff --git a/exports/ipc.js b/exports/ipc.js
index 9d1b1e3ee39..54f57bb0d66 100644
--- a/exports/ipc.js
+++ b/exports/ipc.js
@@ -1,7 +1,9 @@
-module.exports = require('electron').ipcRenderer
+module.exports = require('electron').ipcRenderer;
-const Grim = require('grim')
-Grim.deprecate('Use `require("electron").ipcRenderer` instead of `require("ipc")`')
+const Grim = require('grim');
+Grim.deprecate(
+ 'Use `require("electron").ipcRenderer` instead of `require("ipc")`'
+);
// Ensure each package that requires this shim causes a deprecation warning
-delete require.cache[__filename]
+delete require.cache[__filename];
diff --git a/exports/remote.js b/exports/remote.js
index 379ee43f6be..4e527dbca5e 100644
--- a/exports/remote.js
+++ b/exports/remote.js
@@ -1,7 +1,9 @@
-module.exports = require('electron').remote
+module.exports = require('electron').remote;
-const Grim = require('grim')
-Grim.deprecate('Use `require("electron").remote` instead of `require("remote")`')
+const Grim = require('grim');
+Grim.deprecate(
+ 'Use `require("electron").remote` instead of `require("remote")`'
+);
// Ensure each package that requires this shim causes a deprecation warning
-delete require.cache[__filename]
+delete require.cache[__filename];
diff --git a/exports/shell.js b/exports/shell.js
index 2424455a694..5fd73e772dc 100644
--- a/exports/shell.js
+++ b/exports/shell.js
@@ -1,7 +1,7 @@
-module.exports = require('electron').shell
+module.exports = require('electron').shell;
-const Grim = require('grim')
-Grim.deprecate('Use `require("electron").shell` instead of `require("shell")`')
+const Grim = require('grim');
+Grim.deprecate('Use `require("electron").shell` instead of `require("shell")`');
// Ensure each package that requires this shim causes a deprecation warning
-delete require.cache[__filename]
+delete require.cache[__filename];
diff --git a/exports/web-frame.js b/exports/web-frame.js
index 0c97debfd00..b639ec9aaa1 100644
--- a/exports/web-frame.js
+++ b/exports/web-frame.js
@@ -1,7 +1,9 @@
-module.exports = require('electron').webFrame
+module.exports = require('electron').webFrame;
-const Grim = require('grim')
-Grim.deprecate('Use `require("electron").webFrame` instead of `require("web-frame")`')
+const Grim = require('grim');
+Grim.deprecate(
+ 'Use `require("electron").webFrame` instead of `require("web-frame")`'
+);
// Ensure each package that requires this shim causes a deprecation warning
-delete require.cache[__filename]
+delete require.cache[__filename];
diff --git a/packages/about/lib/about.js b/packages/about/lib/about.js
index 1fe660e9f78..1ec4d8a7280 100644
--- a/packages/about/lib/about.js
+++ b/packages/about/lib/about.js
@@ -1,67 +1,67 @@
-const { CompositeDisposable, Emitter } = require('atom')
-const AboutView = require('./components/about-view')
+const { CompositeDisposable, Emitter } = require('atom');
+const AboutView = require('./components/about-view');
// Deferred requires
-let shell
+let shell;
module.exports = class About {
- constructor (initialState) {
- this.subscriptions = new CompositeDisposable()
- this.emitter = new Emitter()
+ constructor(initialState) {
+ this.subscriptions = new CompositeDisposable();
+ this.emitter = new Emitter();
- this.state = initialState
+ this.state = initialState;
this.views = {
aboutView: null
- }
+ };
this.subscriptions.add(
atom.workspace.addOpener(uriToOpen => {
if (uriToOpen === this.state.uri) {
- return this.deserialize()
+ return this.deserialize();
}
})
- )
+ );
this.subscriptions.add(
atom.commands.add('atom-workspace', 'about:view-release-notes', () => {
- shell = shell || require('electron').shell
+ shell = shell || require('electron').shell;
shell.openExternal(
this.state.updateManager.getReleaseNotesURLForCurrentVersion()
- )
+ );
})
- )
+ );
}
- destroy () {
- if (this.views.aboutView) this.views.aboutView.destroy()
- this.views.aboutView = null
+ destroy() {
+ if (this.views.aboutView) this.views.aboutView.destroy();
+ this.views.aboutView = null;
- if (this.state.updateManager) this.state.updateManager.dispose()
- this.setState({ updateManager: null })
+ if (this.state.updateManager) this.state.updateManager.dispose();
+ this.setState({ updateManager: null });
- this.subscriptions.dispose()
+ this.subscriptions.dispose();
}
- setState (newState) {
+ setState(newState) {
if (newState && typeof newState === 'object') {
- let { state } = this
- this.state = Object.assign({}, state, newState)
+ let { state } = this;
+ this.state = Object.assign({}, state, newState);
- this.didChange()
+ this.didChange();
}
}
- didChange () {
- this.emitter.emit('did-change')
+ didChange() {
+ this.emitter.emit('did-change');
}
- onDidChange (callback) {
- this.emitter.on('did-change', callback)
+ onDidChange(callback) {
+ this.emitter.on('did-change', callback);
}
- deserialize (state) {
+ deserialize(state) {
if (!this.views.aboutView) {
- this.setState(state)
+ this.setState(state);
this.views.aboutView = new AboutView({
uri: this.state.uri,
@@ -71,14 +71,14 @@ module.exports = class About {
currentChromeVersion: this.state.currentChromeVersion,
currentNodeVersion: this.state.currentNodeVersion,
availableVersion: this.state.updateManager.getAvailableVersion()
- })
- this.handleStateChanges()
+ });
+ this.handleStateChanges();
}
- return this.views.aboutView
+ return this.views.aboutView;
}
- handleStateChanges () {
+ handleStateChanges() {
this.onDidChange(() => {
if (this.views.aboutView) {
this.views.aboutView.update({
@@ -88,12 +88,12 @@ module.exports = class About {
currentChromeVersion: this.state.currentChromeVersion,
currentNodeVersion: this.state.currentNodeVersion,
availableVersion: this.state.updateManager.getAvailableVersion()
- })
+ });
}
- })
+ });
this.state.updateManager.onDidChange(() => {
- this.didChange()
- })
+ this.didChange();
+ });
}
-}
+};
diff --git a/packages/about/lib/components/about-status-bar.js b/packages/about/lib/components/about-status-bar.js
index 4529b6ae87a..1456c7bdcf8 100644
--- a/packages/about/lib/components/about-status-bar.js
+++ b/packages/about/lib/components/about-status-bar.js
@@ -1,38 +1,38 @@
-const { CompositeDisposable } = require('atom')
-const etch = require('etch')
-const EtchComponent = require('../etch-component')
+const { CompositeDisposable } = require('atom');
+const etch = require('etch');
+const EtchComponent = require('../etch-component');
-const $ = etch.dom
+const $ = etch.dom;
module.exports = class AboutStatusBar extends EtchComponent {
- constructor () {
- super()
- this.subscriptions = new CompositeDisposable()
+ constructor() {
+ super();
+ this.subscriptions = new CompositeDisposable();
this.subscriptions.add(
atom.tooltips.add(this.element, {
title:
'An update will be installed the next time Atom is relaunched.
Click the squirrel icon for more information.'
})
- )
+ );
}
- handleClick () {
- atom.workspace.open('atom://about')
+ handleClick() {
+ atom.workspace.open('atom://about');
}
- render () {
+ render() {
return $.div(
{
className: 'about-release-notes inline-block',
onclick: this.handleClick.bind(this)
},
$.span({ type: 'button', className: 'icon icon-squirrel' })
- )
+ );
}
- destroy () {
- super.destroy()
- this.subscriptions.dispose()
+ destroy() {
+ super.destroy();
+ this.subscriptions.dispose();
}
-}
+};
diff --git a/packages/about/lib/components/about-view.js b/packages/about/lib/components/about-view.js
index 34fb7cba9a7..b98118551db 100644
--- a/packages/about/lib/components/about-view.js
+++ b/packages/about/lib/components/about-view.js
@@ -1,77 +1,77 @@
-const { Disposable } = require('atom')
-const etch = require('etch')
-const shell = require('shell')
-const AtomLogo = require('./atom-logo')
-const EtchComponent = require('../etch-component')
-const UpdateView = require('./update-view')
+const { Disposable } = require('atom');
+const etch = require('etch');
+const shell = require('shell');
+const AtomLogo = require('./atom-logo');
+const EtchComponent = require('../etch-component');
+const UpdateView = require('./update-view');
-const $ = etch.dom
+const $ = etch.dom;
module.exports = class AboutView extends EtchComponent {
- handleAtomVersionClick (e) {
- e.preventDefault()
- atom.clipboard.write(this.props.currentAtomVersion)
+ handleAtomVersionClick(e) {
+ e.preventDefault();
+ atom.clipboard.write(this.props.currentAtomVersion);
}
- handleElectronVersionClick (e) {
- e.preventDefault()
- atom.clipboard.write(this.props.currentElectronVersion)
+ handleElectronVersionClick(e) {
+ e.preventDefault();
+ atom.clipboard.write(this.props.currentElectronVersion);
}
- handleChromeVersionClick (e) {
- e.preventDefault()
- atom.clipboard.write(this.props.currentChromeVersion)
+ handleChromeVersionClick(e) {
+ e.preventDefault();
+ atom.clipboard.write(this.props.currentChromeVersion);
}
- handleNodeVersionClick (e) {
- e.preventDefault()
- atom.clipboard.write(this.props.currentNodeVersion)
+ handleNodeVersionClick(e) {
+ e.preventDefault();
+ atom.clipboard.write(this.props.currentNodeVersion);
}
- handleReleaseNotesClick (e) {
- e.preventDefault()
+ handleReleaseNotesClick(e) {
+ e.preventDefault();
shell.openExternal(
this.props.updateManager.getReleaseNotesURLForAvailableVersion()
- )
+ );
}
- handleLicenseClick (e) {
- e.preventDefault()
+ handleLicenseClick(e) {
+ e.preventDefault();
atom.commands.dispatch(
atom.views.getView(atom.workspace),
'application:open-license'
- )
+ );
}
- handleTermsOfUseClick (e) {
- e.preventDefault()
- shell.openExternal('https://atom.io/terms')
+ handleTermsOfUseClick(e) {
+ e.preventDefault();
+ shell.openExternal('https://atom.io/terms');
}
- handleHowToUpdateClick (e) {
- e.preventDefault()
+ handleHowToUpdateClick(e) {
+ e.preventDefault();
shell.openExternal(
'https://flight-manual.atom.io/getting-started/sections/installing-atom/'
- )
+ );
}
- handleShowMoreClick (e) {
- e.preventDefault()
- var showMoreDiv = document.querySelector('.show-more')
- var showMoreText = document.querySelector('.about-more-expand')
+ handleShowMoreClick(e) {
+ e.preventDefault();
+ var showMoreDiv = document.querySelector('.show-more');
+ var showMoreText = document.querySelector('.about-more-expand');
switch (showMoreText.textContent) {
case 'Show more':
- showMoreDiv.classList.toggle('hidden')
- showMoreText.textContent = 'Hide'
- break
+ showMoreDiv.classList.toggle('hidden');
+ showMoreText.textContent = 'Hide';
+ break;
case 'Hide':
- showMoreDiv.classList.toggle('hidden')
- showMoreText.textContent = 'Show more'
- break
+ showMoreDiv.classList.toggle('hidden');
+ showMoreText.textContent = 'Show more';
+ break;
}
}
- render () {
+ render() {
return $.div(
{ className: 'pane-item native-key-bindings about' },
$.div(
@@ -204,29 +204,29 @@ module.exports = class AboutView extends EtchComponent {
'Atom Community'
)
)
- )
+ );
}
- serialize () {
+ serialize() {
return {
deserializer: this.constructor.name,
uri: this.props.uri
- }
+ };
}
- onDidChangeTitle () {
- return new Disposable()
+ onDidChangeTitle() {
+ return new Disposable();
}
- onDidChangeModified () {
- return new Disposable()
+ onDidChangeModified() {
+ return new Disposable();
}
- getTitle () {
- return 'About'
+ getTitle() {
+ return 'About';
}
- getIconName () {
- return 'info'
+ getIconName() {
+ return 'info';
}
-}
+};
diff --git a/packages/about/lib/components/atom-logo.js b/packages/about/lib/components/atom-logo.js
index bd50fc7a269..9dcb28dd836 100644
--- a/packages/about/lib/components/atom-logo.js
+++ b/packages/about/lib/components/atom-logo.js
@@ -1,10 +1,10 @@
-const etch = require('etch')
-const EtchComponent = require('../etch-component')
+const etch = require('etch');
+const EtchComponent = require('../etch-component');
-const $ = etch.dom
+const $ = etch.dom;
module.exports = class AtomLogo extends EtchComponent {
- render () {
+ render() {
return $.svg(
{
className: 'about-logo',
@@ -74,6 +74,6 @@ module.exports = class AtomLogo extends EtchComponent {
)
)
)
- )
+ );
}
-}
+};
diff --git a/packages/about/lib/components/update-view.js b/packages/about/lib/components/update-view.js
index 4399b58b439..2475d28ccf4 100644
--- a/packages/about/lib/components/update-view.js
+++ b/packages/about/lib/components/update-view.js
@@ -1,46 +1,46 @@
-const etch = require('etch')
-const EtchComponent = require('../etch-component')
-const UpdateManager = require('../update-manager')
+const etch = require('etch');
+const EtchComponent = require('../etch-component');
+const UpdateManager = require('../update-manager');
-const $ = etch.dom
+const $ = etch.dom;
module.exports = class UpdateView extends EtchComponent {
- constructor (props) {
- super(props)
+ constructor(props) {
+ super(props);
if (
this.props.updateManager.getAutoUpdatesEnabled() &&
this.props.updateManager.getState() === UpdateManager.State.Idle
) {
- this.props.updateManager.checkForUpdate()
+ this.props.updateManager.checkForUpdate();
}
}
- handleAutoUpdateCheckbox (e) {
- atom.config.set('core.automaticallyUpdate', e.target.checked)
+ handleAutoUpdateCheckbox(e) {
+ atom.config.set('core.automaticallyUpdate', e.target.checked);
}
- shouldUpdateActionButtonBeDisabled () {
- let { state } = this.props.updateManager
+ shouldUpdateActionButtonBeDisabled() {
+ let { state } = this.props.updateManager;
return (
state === UpdateManager.State.CheckingForUpdate ||
state === UpdateManager.State.DownloadingUpdate
- )
+ );
}
- executeUpdateAction () {
+ executeUpdateAction() {
if (
this.props.updateManager.state ===
UpdateManager.State.UpdateAvailableToInstall
) {
- this.props.updateManager.restartAndInstallUpdate()
+ this.props.updateManager.restartAndInstallUpdate();
} else {
- this.props.updateManager.checkForUpdate()
+ this.props.updateManager.checkForUpdate();
}
}
- renderUpdateStatus () {
- let updateStatus = ''
+ renderUpdateStatus() {
+ let updateStatus = '';
switch (this.props.updateManager.state) {
case UpdateManager.State.Idle:
@@ -52,8 +52,8 @@ module.exports = class UpdateView extends EtchComponent {
this.props.updateManager.getAutoUpdatesEnabled()
? 'Atom will check for updates automatically'
: 'Automatic updates are disabled please check manually'
- )
- break
+ );
+ break;
case UpdateManager.State.CheckingForUpdate:
updateStatus = $.div(
{ className: 'about-updates-item app-checking-for-updates' },
@@ -61,15 +61,15 @@ module.exports = class UpdateView extends EtchComponent {
{ className: 'about-updates-label icon icon-search' },
'Checking for updates...'
)
- )
- break
+ );
+ break;
case UpdateManager.State.DownloadingUpdate:
updateStatus = $.div(
{ className: 'about-updates-item app-downloading-update' },
$.span({ className: 'loading loading-spinner-tiny inline-block' }),
$.span({ className: 'about-updates-label' }, 'Downloading update')
- )
- break
+ );
+ break;
case UpdateManager.State.UpdateAvailableToInstall:
updateStatus = $.div(
{ className: 'about-updates-item app-update-available-to-install' },
@@ -88,8 +88,8 @@ module.exports = class UpdateView extends EtchComponent {
},
'Release Notes'
)
- )
- break
+ );
+ break;
case UpdateManager.State.UpToDate:
updateStatus = $.div(
{ className: 'about-updates-item app-up-to-date' },
@@ -98,8 +98,8 @@ module.exports = class UpdateView extends EtchComponent {
{ className: 'about-updates-label is-strong' },
'Atom is up to date!'
)
- )
- break
+ );
+ break;
case UpdateManager.State.Unsupported:
updateStatus = $.div(
{ className: 'about-updates-item app-unsupported' },
@@ -114,8 +114,8 @@ module.exports = class UpdateView extends EtchComponent {
},
'How to update'
)
- )
- break
+ );
+ break;
case UpdateManager.State.Error:
updateStatus = $.div(
{ className: 'about-updates-item app-update-error' },
@@ -124,14 +124,14 @@ module.exports = class UpdateView extends EtchComponent {
{ className: 'about-updates-label app-error-message is-strong' },
this.props.updateManager.getErrorMessage()
)
- )
- break
+ );
+ break;
}
- return updateStatus
+ return updateStatus;
}
- render () {
+ render() {
return $.div(
{ className: 'about-updates group-start' },
$.div(
@@ -176,6 +176,6 @@ module.exports = class UpdateView extends EtchComponent {
$.span({}, 'Automatically download updates')
)
)
- )
+ );
}
-}
+};
diff --git a/packages/about/lib/etch-component.js b/packages/about/lib/etch-component.js
index 71ea85c883a..fc6c1bd1b77 100644
--- a/packages/about/lib/etch-component.js
+++ b/packages/about/lib/etch-component.js
@@ -1,15 +1,15 @@
-const etch = require('etch')
+const etch = require('etch');
/*
Public: Abstract class for handling the initialization
boilerplate of an Etch component.
*/
module.exports = class EtchComponent {
- constructor (props) {
- this.props = props
+ constructor(props) {
+ this.props = props;
- etch.initialize(this)
- EtchComponent.setScheduler(atom.views)
+ etch.initialize(this);
+ EtchComponent.setScheduler(atom.views);
}
/*
@@ -17,8 +17,8 @@ module.exports = class EtchComponent {
Returns a {Scheduler}
*/
- static getScheduler () {
- return etch.getScheduler()
+ static getScheduler() {
+ return etch.getScheduler();
}
/*
@@ -26,8 +26,8 @@ module.exports = class EtchComponent {
* `scheduler` {Scheduler}
*/
- static setScheduler (scheduler) {
- etch.setScheduler(scheduler)
+ static setScheduler(scheduler) {
+ etch.setScheduler(scheduler);
}
/*
@@ -37,20 +37,20 @@ module.exports = class EtchComponent {
* `props` an {Object} representing the properties you want to update
*/
- update (props) {
- let oldProps = this.props
- this.props = Object.assign({}, oldProps, props)
- return etch.update(this)
+ update(props) {
+ let oldProps = this.props;
+ this.props = Object.assign({}, oldProps, props);
+ return etch.update(this);
}
/*
Public: Destroys the component, removing it from the DOM.
*/
- destroy () {
- etch.destroy(this)
+ destroy() {
+ etch.destroy(this);
}
- render () {
- throw new Error('Etch components must implement a `render` method')
+ render() {
+ throw new Error('Etch components must implement a `render` method');
}
-}
+};
diff --git a/packages/about/lib/main.js b/packages/about/lib/main.js
index ec1420e7fec..b0cf2cbd4b9 100644
--- a/packages/about/lib/main.js
+++ b/packages/about/lib/main.js
@@ -1,26 +1,26 @@
-const { CompositeDisposable } = require('atom')
-const semver = require('semver')
-const UpdateManager = require('./update-manager')
-const About = require('./about')
-const StatusBarView = require('./components/about-status-bar')
-let updateManager
+const { CompositeDisposable } = require('atom');
+const semver = require('semver');
+const UpdateManager = require('./update-manager');
+const About = require('./about');
+const StatusBarView = require('./components/about-status-bar');
+let updateManager;
// The local storage key for the available update version.
-const AvailableUpdateVersion = 'about:version-available'
-const AboutURI = 'atom://about'
+const AvailableUpdateVersion = 'about:version-available';
+const AboutURI = 'atom://about';
module.exports = {
- activate () {
- this.subscriptions = new CompositeDisposable()
+ activate() {
+ this.subscriptions = new CompositeDisposable();
- this.createModel()
+ this.createModel();
- let availableVersion = window.localStorage.getItem(AvailableUpdateVersion)
+ let availableVersion = window.localStorage.getItem(AvailableUpdateVersion);
if (
atom.getReleaseChannel() === 'dev' ||
(availableVersion && semver.lte(availableVersion, atom.getVersion()))
) {
- this.clearUpdateState()
+ this.clearUpdateState();
}
this.subscriptions.add(
@@ -32,48 +32,48 @@ module.exports = {
window.localStorage.setItem(
AvailableUpdateVersion,
updateManager.getAvailableVersion()
- )
- this.showStatusBarIfNeeded()
+ );
+ this.showStatusBarIfNeeded();
}
})
- )
+ );
this.subscriptions.add(
atom.commands.add('atom-workspace', 'about:clear-update-state', () => {
- this.clearUpdateState()
+ this.clearUpdateState();
})
- )
+ );
},
- deactivate () {
- this.model.destroy()
- if (this.statusBarTile) this.statusBarTile.destroy()
+ deactivate() {
+ this.model.destroy();
+ if (this.statusBarTile) this.statusBarTile.destroy();
if (updateManager) {
- updateManager.dispose()
- updateManager = undefined
+ updateManager.dispose();
+ updateManager = undefined;
}
},
- clearUpdateState () {
- window.localStorage.removeItem(AvailableUpdateVersion)
+ clearUpdateState() {
+ window.localStorage.removeItem(AvailableUpdateVersion);
},
- consumeStatusBar (statusBar) {
- this.statusBar = statusBar
- this.showStatusBarIfNeeded()
+ consumeStatusBar(statusBar) {
+ this.statusBar = statusBar;
+ this.showStatusBarIfNeeded();
},
- deserializeAboutView (state) {
+ deserializeAboutView(state) {
if (!this.model) {
- this.createModel()
+ this.createModel();
}
- return this.model.deserialize(state)
+ return this.model.deserialize(state);
},
- createModel () {
- updateManager = updateManager || new UpdateManager()
+ createModel() {
+ updateManager = updateManager || new UpdateManager();
this.model = new About({
uri: AboutURI,
@@ -82,28 +82,28 @@ module.exports = {
currentChromeVersion: process.versions.chrome,
currentNodeVersion: process.version,
updateManager: updateManager
- })
+ });
},
- isUpdateAvailable () {
- let availableVersion = window.localStorage.getItem(AvailableUpdateVersion)
- return availableVersion && semver.gt(availableVersion, atom.getVersion())
+ isUpdateAvailable() {
+ let availableVersion = window.localStorage.getItem(AvailableUpdateVersion);
+ return availableVersion && semver.gt(availableVersion, atom.getVersion());
},
- showStatusBarIfNeeded () {
+ showStatusBarIfNeeded() {
if (this.isUpdateAvailable() && this.statusBar) {
- let statusBarView = new StatusBarView()
+ let statusBarView = new StatusBarView();
if (this.statusBarTile) {
- this.statusBarTile.destroy()
+ this.statusBarTile.destroy();
}
this.statusBarTile = this.statusBar.addRightTile({
item: statusBarView,
priority: -100
- })
+ });
- return this.statusBarTile
+ return this.statusBarTile;
}
}
-}
+};
diff --git a/packages/about/lib/update-manager.js b/packages/about/lib/update-manager.js
index bae72753d25..eb30ce4d373 100644
--- a/packages/about/lib/update-manager.js
+++ b/packages/about/lib/update-manager.js
@@ -1,46 +1,46 @@
-const { Emitter, CompositeDisposable } = require('atom')
+const { Emitter, CompositeDisposable } = require('atom');
-const Unsupported = 'unsupported'
-const Idle = 'idle'
-const CheckingForUpdate = 'checking'
-const DownloadingUpdate = 'downloading'
-const UpdateAvailableToInstall = 'update-available'
-const UpToDate = 'no-update-available'
-const ErrorState = 'error'
+const Unsupported = 'unsupported';
+const Idle = 'idle';
+const CheckingForUpdate = 'checking';
+const DownloadingUpdate = 'downloading';
+const UpdateAvailableToInstall = 'update-available';
+const UpToDate = 'no-update-available';
+const ErrorState = 'error';
let UpdateManager = class UpdateManager {
- constructor () {
- this.emitter = new Emitter()
- this.currentVersion = atom.getVersion()
- this.availableVersion = atom.getVersion()
- this.resetState()
- this.listenForAtomEvents()
+ constructor() {
+ this.emitter = new Emitter();
+ this.currentVersion = atom.getVersion();
+ this.availableVersion = atom.getVersion();
+ this.resetState();
+ this.listenForAtomEvents();
}
- listenForAtomEvents () {
- this.subscriptions = new CompositeDisposable()
+ listenForAtomEvents() {
+ this.subscriptions = new CompositeDisposable();
this.subscriptions.add(
atom.autoUpdater.onDidBeginCheckingForUpdate(() => {
- this.setState(CheckingForUpdate)
+ this.setState(CheckingForUpdate);
}),
atom.autoUpdater.onDidBeginDownloadingUpdate(() => {
- this.setState(DownloadingUpdate)
+ this.setState(DownloadingUpdate);
}),
atom.autoUpdater.onDidCompleteDownloadingUpdate(({ releaseVersion }) => {
- this.setAvailableVersion(releaseVersion)
+ this.setAvailableVersion(releaseVersion);
}),
atom.autoUpdater.onUpdateNotAvailable(() => {
- this.setState(UpToDate)
+ this.setState(UpToDate);
}),
atom.autoUpdater.onUpdateError(() => {
- this.setState(ErrorState)
+ this.setState(ErrorState);
}),
atom.config.observe('core.automaticallyUpdate', value => {
- this.autoUpdatesEnabled = value
- this.emitDidChange()
+ this.autoUpdatesEnabled = value;
+ this.emitDidChange();
})
- )
+ );
// TODO: When https://github.com/atom/electron/issues/4587 is closed we can add this support.
// atom.autoUpdater.onUpdateAvailable =>
@@ -48,95 +48,95 @@ let UpdateManager = class UpdateManager {
// @updateAvailable.addClass('is-shown')
}
- dispose () {
- this.subscriptions.dispose()
+ dispose() {
+ this.subscriptions.dispose();
}
- onDidChange (callback) {
- return this.emitter.on('did-change', callback)
+ onDidChange(callback) {
+ return this.emitter.on('did-change', callback);
}
- emitDidChange () {
- this.emitter.emit('did-change')
+ emitDidChange() {
+ this.emitter.emit('did-change');
}
- getAutoUpdatesEnabled () {
+ getAutoUpdatesEnabled() {
return (
this.autoUpdatesEnabled && this.state !== UpdateManager.State.Unsupported
- )
+ );
}
- setAutoUpdatesEnabled (enabled) {
- return atom.config.set('core.automaticallyUpdate', enabled)
+ setAutoUpdatesEnabled(enabled) {
+ return atom.config.set('core.automaticallyUpdate', enabled);
}
- getErrorMessage () {
- return atom.autoUpdater.getErrorMessage()
+ getErrorMessage() {
+ return atom.autoUpdater.getErrorMessage();
}
- getState () {
- return this.state
+ getState() {
+ return this.state;
}
- setState (state) {
- this.state = state
- this.emitDidChange()
+ setState(state) {
+ this.state = state;
+ this.emitDidChange();
}
- resetState () {
+ resetState() {
this.state = atom.autoUpdater.platformSupportsUpdates()
? atom.autoUpdater.getState()
- : Unsupported
- this.emitDidChange()
+ : Unsupported;
+ this.emitDidChange();
}
- getAvailableVersion () {
- return this.availableVersion
+ getAvailableVersion() {
+ return this.availableVersion;
}
- setAvailableVersion (version) {
- this.availableVersion = version
+ setAvailableVersion(version) {
+ this.availableVersion = version;
if (this.availableVersion !== this.currentVersion) {
- this.state = UpdateAvailableToInstall
+ this.state = UpdateAvailableToInstall;
} else {
- this.state = UpToDate
+ this.state = UpToDate;
}
- this.emitDidChange()
+ this.emitDidChange();
}
- checkForUpdate () {
- atom.autoUpdater.checkForUpdate()
+ checkForUpdate() {
+ atom.autoUpdater.checkForUpdate();
}
- restartAndInstallUpdate () {
- atom.autoUpdater.restartAndInstallUpdate()
+ restartAndInstallUpdate() {
+ atom.autoUpdater.restartAndInstallUpdate();
}
- getReleaseNotesURLForCurrentVersion () {
- return this.getReleaseNotesURLForVersion(this.currentVersion)
+ getReleaseNotesURLForCurrentVersion() {
+ return this.getReleaseNotesURLForVersion(this.currentVersion);
}
- getReleaseNotesURLForAvailableVersion () {
- return this.getReleaseNotesURLForVersion(this.availableVersion)
+ getReleaseNotesURLForAvailableVersion() {
+ return this.getReleaseNotesURLForVersion(this.availableVersion);
}
- getReleaseNotesURLForVersion (appVersion) {
+ getReleaseNotesURLForVersion(appVersion) {
// Dev versions will not have a releases page
if (appVersion.indexOf('dev') > -1) {
- return 'https://atom.io/releases'
+ return 'https://atom.io/releases';
}
if (!appVersion.startsWith('v')) {
- appVersion = `v${appVersion}`
+ appVersion = `v${appVersion}`;
}
const releaseRepo =
- appVersion.indexOf('nightly') > -1 ? 'atom-nightly-releases' : 'atom'
- return `https://github.com/atom/${releaseRepo}/releases/tag/${appVersion}`
+ appVersion.indexOf('nightly') > -1 ? 'atom-nightly-releases' : 'atom';
+ return `https://github.com/atom/${releaseRepo}/releases/tag/${appVersion}`;
}
-}
+};
UpdateManager.State = {
Unsupported: Unsupported,
@@ -146,6 +146,6 @@ UpdateManager.State = {
UpdateAvailableToInstall: UpdateAvailableToInstall,
UpToDate: UpToDate,
Error: ErrorState
-}
+};
-module.exports = UpdateManager
+module.exports = UpdateManager;
diff --git a/packages/about/spec/about-spec.js b/packages/about/spec/about-spec.js
index 21aa4c5eb56..5fe78a1356a 100644
--- a/packages/about/spec/about-spec.js
+++ b/packages/about/spec/about-spec.js
@@ -1,28 +1,28 @@
describe('About', () => {
- let workspaceElement
+ let workspaceElement;
beforeEach(async () => {
- let storage = {}
+ let storage = {};
spyOn(window.localStorage, 'setItem').andCallFake((key, value) => {
- storage[key] = value
- })
+ storage[key] = value;
+ });
spyOn(window.localStorage, 'getItem').andCallFake(key => {
- return storage[key]
- })
+ return storage[key];
+ });
- workspaceElement = atom.views.getView(atom.workspace)
- await atom.packages.activatePackage('about')
- })
+ workspaceElement = atom.views.getView(atom.workspace);
+ await atom.packages.activatePackage('about');
+ });
it('deserializes correctly', () => {
let deserializedAboutView = atom.deserializers.deserialize({
deserializer: 'AboutView',
uri: 'atom://about'
- })
+ });
- expect(deserializedAboutView).toBeTruthy()
- })
+ expect(deserializedAboutView).toBeTruthy();
+ });
describe('when the about:about-atom command is triggered', () => {
it('shows the About Atom view', async () => {
@@ -30,70 +30,70 @@ describe('About', () => {
// `toBeVisible()` matchers to work. Anything testing visibility or focus
// requires that the workspaceElement is on the DOM. Tests that attach the
// workspaceElement to the DOM are generally slower than those off DOM.
- jasmine.attachToDOM(workspaceElement)
+ jasmine.attachToDOM(workspaceElement);
- expect(workspaceElement.querySelector('.about')).not.toExist()
- await atom.workspace.open('atom://about')
+ expect(workspaceElement.querySelector('.about')).not.toExist();
+ await atom.workspace.open('atom://about');
- let aboutElement = workspaceElement.querySelector('.about')
- expect(aboutElement).toBeVisible()
- })
- })
+ let aboutElement = workspaceElement.querySelector('.about');
+ expect(aboutElement).toBeVisible();
+ });
+ });
describe('when the Atom version number is clicked', () => {
it('copies the version number to the clipboard', async () => {
- await atom.workspace.open('atom://about')
+ await atom.workspace.open('atom://about');
- let aboutElement = workspaceElement.querySelector('.about')
- let versionContainer = aboutElement.querySelector('.atom')
- versionContainer.click()
- expect(atom.clipboard.read()).toBe(atom.getVersion())
- })
- })
+ let aboutElement = workspaceElement.querySelector('.about');
+ let versionContainer = aboutElement.querySelector('.atom');
+ versionContainer.click();
+ expect(atom.clipboard.read()).toBe(atom.getVersion());
+ });
+ });
describe('when the show more link is clicked', () => {
it('expands to show additional version numbers', async () => {
- await atom.workspace.open('atom://about')
- jasmine.attachToDOM(workspaceElement)
+ await atom.workspace.open('atom://about');
+ jasmine.attachToDOM(workspaceElement);
- let aboutElement = workspaceElement.querySelector('.about')
- let showMoreElement = aboutElement.querySelector('.show-more-expand')
- let moreInfoElement = workspaceElement.querySelector('.show-more')
- showMoreElement.click()
- expect(moreInfoElement).toBeVisible()
- })
- })
+ let aboutElement = workspaceElement.querySelector('.about');
+ let showMoreElement = aboutElement.querySelector('.show-more-expand');
+ let moreInfoElement = workspaceElement.querySelector('.show-more');
+ showMoreElement.click();
+ expect(moreInfoElement).toBeVisible();
+ });
+ });
describe('when the Electron version number is clicked', () => {
it('copies the version number to the clipboard', async () => {
- await atom.workspace.open('atom://about')
+ await atom.workspace.open('atom://about');
- let aboutElement = workspaceElement.querySelector('.about')
- let versionContainer = aboutElement.querySelector('.electron')
- versionContainer.click()
- expect(atom.clipboard.read()).toBe(process.versions.electron)
- })
- })
+ let aboutElement = workspaceElement.querySelector('.about');
+ let versionContainer = aboutElement.querySelector('.electron');
+ versionContainer.click();
+ expect(atom.clipboard.read()).toBe(process.versions.electron);
+ });
+ });
describe('when the Chrome version number is clicked', () => {
it('copies the version number to the clipboard', async () => {
- await atom.workspace.open('atom://about')
+ await atom.workspace.open('atom://about');
- let aboutElement = workspaceElement.querySelector('.about')
- let versionContainer = aboutElement.querySelector('.chrome')
- versionContainer.click()
- expect(atom.clipboard.read()).toBe(process.versions.chrome)
- })
- })
+ let aboutElement = workspaceElement.querySelector('.about');
+ let versionContainer = aboutElement.querySelector('.chrome');
+ versionContainer.click();
+ expect(atom.clipboard.read()).toBe(process.versions.chrome);
+ });
+ });
describe('when the Node version number is clicked', () => {
it('copies the version number to the clipboard', async () => {
- await atom.workspace.open('atom://about')
-
- let aboutElement = workspaceElement.querySelector('.about')
- let versionContainer = aboutElement.querySelector('.node')
- versionContainer.click()
- expect(atom.clipboard.read()).toBe(process.version)
- })
- })
-})
+ await atom.workspace.open('atom://about');
+
+ let aboutElement = workspaceElement.querySelector('.about');
+ let versionContainer = aboutElement.querySelector('.node');
+ versionContainer.click();
+ expect(atom.clipboard.read()).toBe(process.version);
+ });
+ });
+});
diff --git a/packages/about/spec/about-status-bar-spec.js b/packages/about/spec/about-status-bar-spec.js
index a67c0511c32..157842f3ea9 100644
--- a/packages/about/spec/about-status-bar-spec.js
+++ b/packages/about/spec/about-status-bar-spec.js
@@ -1,179 +1,183 @@
-const { conditionPromise } = require('./helpers/async-spec-helpers')
-const MockUpdater = require('./mocks/updater')
+const { conditionPromise } = require('./helpers/async-spec-helpers');
+const MockUpdater = require('./mocks/updater');
describe('the status bar', () => {
- let atomVersion
- let workspaceElement
+ let atomVersion;
+ let workspaceElement;
beforeEach(async () => {
- let storage = {}
+ let storage = {};
spyOn(window.localStorage, 'setItem').andCallFake((key, value) => {
- storage[key] = value
- })
+ storage[key] = value;
+ });
spyOn(window.localStorage, 'getItem').andCallFake(key => {
- return storage[key]
- })
+ return storage[key];
+ });
spyOn(atom, 'getVersion').andCallFake(() => {
- return atomVersion
- })
+ return atomVersion;
+ });
- workspaceElement = atom.views.getView(atom.workspace)
+ workspaceElement = atom.views.getView(atom.workspace);
- await atom.packages.activatePackage('status-bar')
- await atom.workspace.open('sample.js')
- })
+ await atom.packages.activatePackage('status-bar');
+ await atom.workspace.open('sample.js');
+ });
afterEach(async () => {
- await atom.packages.deactivatePackage('about')
- await atom.packages.deactivatePackage('status-bar')
- })
+ await atom.packages.deactivatePackage('about');
+ await atom.packages.deactivatePackage('status-bar');
+ });
- describe('on a stable version', function () {
+ describe('on a stable version', function() {
beforeEach(async () => {
- atomVersion = '1.2.3'
+ atomVersion = '1.2.3';
- await atom.packages.activatePackage('about')
- })
+ await atom.packages.activatePackage('about');
+ });
describe('with no update', () => {
it('does not show the view', () => {
- expect(workspaceElement).not.toContain('.about-release-notes')
- })
- })
+ expect(workspaceElement).not.toContain('.about-release-notes');
+ });
+ });
describe('with an update', () => {
it('shows the view when the update finishes downloading', () => {
- MockUpdater.finishDownloadingUpdate('42.0.0')
- expect(workspaceElement).toContain('.about-release-notes')
- })
+ MockUpdater.finishDownloadingUpdate('42.0.0');
+ expect(workspaceElement).toContain('.about-release-notes');
+ });
describe('clicking on the status', () => {
it('opens the about page', async () => {
- MockUpdater.finishDownloadingUpdate('42.0.0')
- workspaceElement.querySelector('.about-release-notes').click()
- await conditionPromise(() => workspaceElement.querySelector('.about'))
- expect(workspaceElement.querySelector('.about')).toExist()
- })
- })
+ MockUpdater.finishDownloadingUpdate('42.0.0');
+ workspaceElement.querySelector('.about-release-notes').click();
+ await conditionPromise(() =>
+ workspaceElement.querySelector('.about')
+ );
+ expect(workspaceElement.querySelector('.about')).toExist();
+ });
+ });
it('continues to show the squirrel until Atom is updated to the new version', async () => {
- MockUpdater.finishDownloadingUpdate('42.0.0')
- expect(workspaceElement).toContain('.about-release-notes')
+ MockUpdater.finishDownloadingUpdate('42.0.0');
+ expect(workspaceElement).toContain('.about-release-notes');
- await atom.packages.deactivatePackage('about')
- expect(workspaceElement).not.toContain('.about-release-notes')
+ await atom.packages.deactivatePackage('about');
+ expect(workspaceElement).not.toContain('.about-release-notes');
- await atom.packages.activatePackage('about')
- await Promise.resolve() // Service consumption hooks are deferred until the next tick
- expect(workspaceElement).toContain('.about-release-notes')
+ await atom.packages.activatePackage('about');
+ await Promise.resolve(); // Service consumption hooks are deferred until the next tick
+ expect(workspaceElement).toContain('.about-release-notes');
- await atom.packages.deactivatePackage('about')
- expect(workspaceElement).not.toContain('.about-release-notes')
+ await atom.packages.deactivatePackage('about');
+ expect(workspaceElement).not.toContain('.about-release-notes');
- atomVersion = '42.0.0'
- await atom.packages.activatePackage('about')
+ atomVersion = '42.0.0';
+ await atom.packages.activatePackage('about');
- await Promise.resolve() // Service consumption hooks are deferred until the next tick
- expect(workspaceElement).not.toContain('.about-release-notes')
- })
+ await Promise.resolve(); // Service consumption hooks are deferred until the next tick
+ expect(workspaceElement).not.toContain('.about-release-notes');
+ });
it('does not show the view if Atom is updated to a newer version than notified', async () => {
- MockUpdater.finishDownloadingUpdate('42.0.0')
+ MockUpdater.finishDownloadingUpdate('42.0.0');
- await atom.packages.deactivatePackage('about')
+ await atom.packages.deactivatePackage('about');
- atomVersion = '43.0.0'
- await atom.packages.activatePackage('about')
+ atomVersion = '43.0.0';
+ await atom.packages.activatePackage('about');
- await Promise.resolve() // Service consumption hooks are deferred until the next tick
- expect(workspaceElement).not.toContain('.about-release-notes')
- })
- })
- })
+ await Promise.resolve(); // Service consumption hooks are deferred until the next tick
+ expect(workspaceElement).not.toContain('.about-release-notes');
+ });
+ });
+ });
- describe('on a beta version', function () {
+ describe('on a beta version', function() {
beforeEach(async () => {
- atomVersion = '1.2.3-beta4'
+ atomVersion = '1.2.3-beta4';
- await atom.packages.activatePackage('about')
- })
+ await atom.packages.activatePackage('about');
+ });
describe('with no update', () => {
it('does not show the view', () => {
- expect(workspaceElement).not.toContain('.about-release-notes')
- })
- })
+ expect(workspaceElement).not.toContain('.about-release-notes');
+ });
+ });
describe('with an update', () => {
it('shows the view when the update finishes downloading', () => {
- MockUpdater.finishDownloadingUpdate('42.0.0')
- expect(workspaceElement).toContain('.about-release-notes')
- })
+ MockUpdater.finishDownloadingUpdate('42.0.0');
+ expect(workspaceElement).toContain('.about-release-notes');
+ });
describe('clicking on the status', () => {
it('opens the about page', async () => {
- MockUpdater.finishDownloadingUpdate('42.0.0')
- workspaceElement.querySelector('.about-release-notes').click()
- await conditionPromise(() => workspaceElement.querySelector('.about'))
- expect(workspaceElement.querySelector('.about')).toExist()
- })
- })
+ MockUpdater.finishDownloadingUpdate('42.0.0');
+ workspaceElement.querySelector('.about-release-notes').click();
+ await conditionPromise(() =>
+ workspaceElement.querySelector('.about')
+ );
+ expect(workspaceElement.querySelector('.about')).toExist();
+ });
+ });
it('continues to show the squirrel until Atom is updated to the new version', async () => {
- MockUpdater.finishDownloadingUpdate('42.0.0')
- expect(workspaceElement).toContain('.about-release-notes')
+ MockUpdater.finishDownloadingUpdate('42.0.0');
+ expect(workspaceElement).toContain('.about-release-notes');
- await atom.packages.deactivatePackage('about')
- expect(workspaceElement).not.toContain('.about-release-notes')
+ await atom.packages.deactivatePackage('about');
+ expect(workspaceElement).not.toContain('.about-release-notes');
- await atom.packages.activatePackage('about')
- await Promise.resolve() // Service consumption hooks are deferred until the next tick
- expect(workspaceElement).toContain('.about-release-notes')
+ await atom.packages.activatePackage('about');
+ await Promise.resolve(); // Service consumption hooks are deferred until the next tick
+ expect(workspaceElement).toContain('.about-release-notes');
- await atom.packages.deactivatePackage('about')
- expect(workspaceElement).not.toContain('.about-release-notes')
+ await atom.packages.deactivatePackage('about');
+ expect(workspaceElement).not.toContain('.about-release-notes');
- atomVersion = '42.0.0'
- await atom.packages.activatePackage('about')
+ atomVersion = '42.0.0';
+ await atom.packages.activatePackage('about');
- await Promise.resolve() // Service consumption hooks are deferred until the next tick
- expect(workspaceElement).not.toContain('.about-release-notes')
- })
+ await Promise.resolve(); // Service consumption hooks are deferred until the next tick
+ expect(workspaceElement).not.toContain('.about-release-notes');
+ });
it('does not show the view if Atom is updated to a newer version than notified', async () => {
- MockUpdater.finishDownloadingUpdate('42.0.0')
+ MockUpdater.finishDownloadingUpdate('42.0.0');
- await atom.packages.deactivatePackage('about')
+ await atom.packages.deactivatePackage('about');
- atomVersion = '43.0.0'
- await atom.packages.activatePackage('about')
+ atomVersion = '43.0.0';
+ await atom.packages.activatePackage('about');
- await Promise.resolve() // Service consumption hooks are deferred until the next tick
- expect(workspaceElement).not.toContain('.about-release-notes')
- })
- })
- })
+ await Promise.resolve(); // Service consumption hooks are deferred until the next tick
+ expect(workspaceElement).not.toContain('.about-release-notes');
+ });
+ });
+ });
- describe('on a development version', function () {
+ describe('on a development version', function() {
beforeEach(async () => {
- atomVersion = '1.2.3-dev-0123abcd'
+ atomVersion = '1.2.3-dev-0123abcd';
- await atom.packages.activatePackage('about')
- })
+ await atom.packages.activatePackage('about');
+ });
describe('with no update', () => {
it('does not show the view', () => {
- expect(workspaceElement).not.toContain('.about-release-notes')
- })
- })
+ expect(workspaceElement).not.toContain('.about-release-notes');
+ });
+ });
describe('with a previously downloaded update', () => {
it('does not show the view', () => {
- window.localStorage.setItem('about:version-available', '42.0.0')
+ window.localStorage.setItem('about:version-available', '42.0.0');
- expect(workspaceElement).not.toContain('.about-release-notes')
- })
- })
- })
-})
+ expect(workspaceElement).not.toContain('.about-release-notes');
+ });
+ });
+ });
+});
diff --git a/packages/about/spec/helpers/async-spec-helpers.js b/packages/about/spec/helpers/async-spec-helpers.js
index 58e17d323af..c73ac5062da 100644
--- a/packages/about/spec/helpers/async-spec-helpers.js
+++ b/packages/about/spec/helpers/async-spec-helpers.js
@@ -1,26 +1,26 @@
/** @babel */
-const { now } = Date
-const { setTimeout } = global
+const { now } = Date;
+const { setTimeout } = global;
-export async function conditionPromise (condition) {
- const startTime = now()
+export async function conditionPromise(condition) {
+ const startTime = now();
while (true) {
- await timeoutPromise(100)
+ await timeoutPromise(100);
if (await condition()) {
- return
+ return;
}
if (now() - startTime > 5000) {
- throw new Error('Timed out waiting on condition')
+ throw new Error('Timed out waiting on condition');
}
}
}
-export function timeoutPromise (timeout) {
- return new Promise(function (resolve) {
- setTimeout(resolve, timeout)
- })
+export function timeoutPromise(timeout) {
+ return new Promise(function(resolve) {
+ setTimeout(resolve, timeout);
+ });
}
diff --git a/packages/about/spec/mocks/updater.js b/packages/about/spec/mocks/updater.js
index 6c5e1f19d38..e0f0a311dfc 100644
--- a/packages/about/spec/mocks/updater.js
+++ b/packages/about/spec/mocks/updater.js
@@ -1,23 +1,23 @@
module.exports = {
- updateError () {
- atom.autoUpdater.emitter.emit('update-error')
+ updateError() {
+ atom.autoUpdater.emitter.emit('update-error');
},
- checkForUpdate () {
- atom.autoUpdater.emitter.emit('did-begin-checking-for-update')
+ checkForUpdate() {
+ atom.autoUpdater.emitter.emit('did-begin-checking-for-update');
},
- updateNotAvailable () {
- atom.autoUpdater.emitter.emit('update-not-available')
+ updateNotAvailable() {
+ atom.autoUpdater.emitter.emit('update-not-available');
},
- downloadUpdate () {
- atom.autoUpdater.emitter.emit('did-begin-downloading-update')
+ downloadUpdate() {
+ atom.autoUpdater.emitter.emit('did-begin-downloading-update');
},
- finishDownloadingUpdate (releaseVersion) {
+ finishDownloadingUpdate(releaseVersion) {
atom.autoUpdater.emitter.emit('did-complete-downloading-update', {
releaseVersion
- })
+ });
}
-}
+};
diff --git a/packages/about/spec/update-manager-spec.js b/packages/about/spec/update-manager-spec.js
index cc395949e19..ef42fec9b52 100644
--- a/packages/about/spec/update-manager-spec.js
+++ b/packages/about/spec/update-manager-spec.js
@@ -1,32 +1,32 @@
-const UpdateManager = require('../lib/update-manager')
+const UpdateManager = require('../lib/update-manager');
describe('UpdateManager', () => {
- let updateManager
+ let updateManager;
beforeEach(() => {
- updateManager = new UpdateManager()
- })
+ updateManager = new UpdateManager();
+ });
describe('::getReleaseNotesURLForVersion', () => {
it('returns atom.io releases when dev version', () => {
expect(
updateManager.getReleaseNotesURLForVersion('1.7.0-dev-e44b57d')
- ).toContain('atom.io/releases')
- })
+ ).toContain('atom.io/releases');
+ });
it('returns the page for the release when not a dev version', () => {
expect(updateManager.getReleaseNotesURLForVersion('1.7.0')).toContain(
'atom/atom/releases/tag/v1.7.0'
- )
+ );
expect(updateManager.getReleaseNotesURLForVersion('v1.7.0')).toContain(
'atom/atom/releases/tag/v1.7.0'
- )
+ );
expect(
updateManager.getReleaseNotesURLForVersion('1.7.0-beta10')
- ).toContain('atom/atom/releases/tag/v1.7.0-beta10')
+ ).toContain('atom/atom/releases/tag/v1.7.0-beta10');
expect(
updateManager.getReleaseNotesURLForVersion('1.7.0-nightly10')
- ).toContain('atom/atom-nightly-releases/releases/tag/v1.7.0-nightly10')
- })
- })
-})
+ ).toContain('atom/atom-nightly-releases/releases/tag/v1.7.0-nightly10');
+ });
+ });
+});
diff --git a/packages/about/spec/update-view-spec.js b/packages/about/spec/update-view-spec.js
index 8e6587b59f7..83620e4e5cd 100644
--- a/packages/about/spec/update-view-spec.js
+++ b/packages/about/spec/update-view-spec.js
@@ -1,385 +1,387 @@
-const { shell } = require('electron')
-const main = require('../lib/main')
-const AboutView = require('../lib/components/about-view')
-const UpdateView = require('../lib/components/update-view')
-const MockUpdater = require('./mocks/updater')
+const { shell } = require('electron');
+const main = require('../lib/main');
+const AboutView = require('../lib/components/about-view');
+const UpdateView = require('../lib/components/update-view');
+const MockUpdater = require('./mocks/updater');
describe('UpdateView', () => {
- let aboutElement
- let updateManager
- let workspaceElement
- let scheduler
+ let aboutElement;
+ let updateManager;
+ let workspaceElement;
+ let scheduler;
beforeEach(async () => {
- let storage = {}
+ let storage = {};
spyOn(window.localStorage, 'setItem').andCallFake((key, value) => {
- storage[key] = value
- })
+ storage[key] = value;
+ });
spyOn(window.localStorage, 'getItem').andCallFake(key => {
- return storage[key]
- })
+ return storage[key];
+ });
- workspaceElement = atom.views.getView(atom.workspace)
- await atom.packages.activatePackage('about')
- spyOn(atom.autoUpdater, 'getState').andReturn('idle')
- spyOn(atom.autoUpdater, 'checkForUpdate')
- spyOn(atom.autoUpdater, 'platformSupportsUpdates').andReturn(true)
- })
+ workspaceElement = atom.views.getView(atom.workspace);
+ await atom.packages.activatePackage('about');
+ spyOn(atom.autoUpdater, 'getState').andReturn('idle');
+ spyOn(atom.autoUpdater, 'checkForUpdate');
+ spyOn(atom.autoUpdater, 'platformSupportsUpdates').andReturn(true);
+ });
describe('when the About page is open', () => {
beforeEach(async () => {
- jasmine.attachToDOM(workspaceElement)
- await atom.workspace.open('atom://about')
- aboutElement = workspaceElement.querySelector('.about')
- updateManager = main.model.state.updateManager
- scheduler = AboutView.getScheduler()
- })
+ jasmine.attachToDOM(workspaceElement);
+ await atom.workspace.open('atom://about');
+ aboutElement = workspaceElement.querySelector('.about');
+ updateManager = main.model.state.updateManager;
+ scheduler = AboutView.getScheduler();
+ });
describe('when the updates are not supported by the platform', () => {
beforeEach(async () => {
- atom.autoUpdater.platformSupportsUpdates.andReturn(false)
- updateManager.resetState()
- await scheduler.getNextUpdatePromise()
- })
+ atom.autoUpdater.platformSupportsUpdates.andReturn(false);
+ updateManager.resetState();
+ await scheduler.getNextUpdatePromise();
+ });
it('hides the auto update UI and shows the update instructions link', async () => {
expect(
aboutElement.querySelector('.about-update-action-button')
- ).not.toBeVisible()
+ ).not.toBeVisible();
expect(
aboutElement.querySelector('.about-auto-updates')
- ).not.toBeVisible()
- })
+ ).not.toBeVisible();
+ });
it('opens the update instructions page when the instructions link is clicked', async () => {
- spyOn(shell, 'openExternal')
+ spyOn(shell, 'openExternal');
let link = aboutElement.querySelector(
'.app-unsupported .about-updates-instructions'
- )
- link.click()
+ );
+ link.click();
- let args = shell.openExternal.mostRecentCall.args
- expect(shell.openExternal).toHaveBeenCalled()
- expect(args[0]).toContain('installing-atom')
- })
- })
+ let args = shell.openExternal.mostRecentCall.args;
+ expect(shell.openExternal).toHaveBeenCalled();
+ expect(args[0]).toContain('installing-atom');
+ });
+ });
describe('when updates are supported by the platform', () => {
beforeEach(async () => {
- atom.autoUpdater.platformSupportsUpdates.andReturn(true)
- updateManager.resetState()
- await scheduler.getNextUpdatePromise()
- })
+ atom.autoUpdater.platformSupportsUpdates.andReturn(true);
+ updateManager.resetState();
+ await scheduler.getNextUpdatePromise();
+ });
it('shows the auto update UI', () => {
- expect(aboutElement.querySelector('.about-updates')).toBeVisible()
- })
+ expect(aboutElement.querySelector('.about-updates')).toBeVisible();
+ });
it('shows the correct panels when the app checks for updates and there is no update available', async () => {
expect(
aboutElement.querySelector('.about-default-update-message')
- ).toBeVisible()
+ ).toBeVisible();
- MockUpdater.checkForUpdate()
- await scheduler.getNextUpdatePromise()
- expect(aboutElement.querySelector('.app-up-to-date')).not.toBeVisible()
+ MockUpdater.checkForUpdate();
+ await scheduler.getNextUpdatePromise();
+ expect(aboutElement.querySelector('.app-up-to-date')).not.toBeVisible();
expect(
aboutElement.querySelector('.app-checking-for-updates')
- ).toBeVisible()
+ ).toBeVisible();
- MockUpdater.updateNotAvailable()
- await scheduler.getNextUpdatePromise()
- expect(aboutElement.querySelector('.app-up-to-date')).toBeVisible()
+ MockUpdater.updateNotAvailable();
+ await scheduler.getNextUpdatePromise();
+ expect(aboutElement.querySelector('.app-up-to-date')).toBeVisible();
expect(
aboutElement.querySelector('.app-checking-for-updates')
- ).not.toBeVisible()
- })
+ ).not.toBeVisible();
+ });
it('shows the correct panels when the app checks for updates and encounters an error', async () => {
expect(
aboutElement.querySelector('.about-default-update-message')
- ).toBeVisible()
+ ).toBeVisible();
- MockUpdater.checkForUpdate()
- await scheduler.getNextUpdatePromise()
- expect(aboutElement.querySelector('.app-up-to-date')).not.toBeVisible()
+ MockUpdater.checkForUpdate();
+ await scheduler.getNextUpdatePromise();
+ expect(aboutElement.querySelector('.app-up-to-date')).not.toBeVisible();
expect(
aboutElement.querySelector('.app-checking-for-updates')
- ).toBeVisible()
-
- spyOn(atom.autoUpdater, 'getErrorMessage').andReturn('an error message')
- MockUpdater.updateError()
- await scheduler.getNextUpdatePromise()
- expect(aboutElement.querySelector('.app-update-error')).toBeVisible()
+ ).toBeVisible();
+
+ spyOn(atom.autoUpdater, 'getErrorMessage').andReturn(
+ 'an error message'
+ );
+ MockUpdater.updateError();
+ await scheduler.getNextUpdatePromise();
+ expect(aboutElement.querySelector('.app-update-error')).toBeVisible();
expect(
aboutElement.querySelector('.app-error-message').textContent
- ).toBe('an error message')
+ ).toBe('an error message');
expect(
aboutElement.querySelector('.app-checking-for-updates')
- ).not.toBeVisible()
+ ).not.toBeVisible();
expect(
aboutElement.querySelector('.about-update-action-button').disabled
- ).toBe(false)
+ ).toBe(false);
expect(
aboutElement.querySelector('.about-update-action-button').textContent
- ).toBe('Check now')
- })
+ ).toBe('Check now');
+ });
it('shows the correct panels and button states when the app checks for updates and an update is downloaded', async () => {
expect(
aboutElement.querySelector('.about-default-update-message')
- ).toBeVisible()
+ ).toBeVisible();
expect(
aboutElement.querySelector('.about-update-action-button').disabled
- ).toBe(false)
+ ).toBe(false);
expect(
aboutElement.querySelector('.about-update-action-button').textContent
- ).toBe('Check now')
+ ).toBe('Check now');
- MockUpdater.checkForUpdate()
- await scheduler.getNextUpdatePromise()
+ MockUpdater.checkForUpdate();
+ await scheduler.getNextUpdatePromise();
- expect(aboutElement.querySelector('.app-up-to-date')).not.toBeVisible()
+ expect(aboutElement.querySelector('.app-up-to-date')).not.toBeVisible();
expect(
aboutElement.querySelector('.app-checking-for-updates')
- ).toBeVisible()
+ ).toBeVisible();
expect(
aboutElement.querySelector('.about-update-action-button').disabled
- ).toBe(true)
+ ).toBe(true);
expect(
aboutElement.querySelector('.about-update-action-button').textContent
- ).toBe('Check now')
+ ).toBe('Check now');
- MockUpdater.downloadUpdate()
- await scheduler.getNextUpdatePromise()
+ MockUpdater.downloadUpdate();
+ await scheduler.getNextUpdatePromise();
expect(
aboutElement.querySelector('.app-checking-for-updates')
- ).not.toBeVisible()
+ ).not.toBeVisible();
expect(
aboutElement.querySelector('.app-downloading-update')
- ).toBeVisible()
+ ).toBeVisible();
// TODO: at some point it would be nice to be able to cancel an update download, and then this would be a cancel button
expect(
aboutElement.querySelector('.about-update-action-button').disabled
- ).toBe(true)
+ ).toBe(true);
expect(
aboutElement.querySelector('.about-update-action-button').textContent
- ).toBe('Check now')
+ ).toBe('Check now');
- MockUpdater.finishDownloadingUpdate('42.0.0')
- await scheduler.getNextUpdatePromise()
+ MockUpdater.finishDownloadingUpdate('42.0.0');
+ await scheduler.getNextUpdatePromise();
expect(
aboutElement.querySelector('.app-downloading-update')
- ).not.toBeVisible()
+ ).not.toBeVisible();
expect(
aboutElement.querySelector('.app-update-available-to-install')
- ).toBeVisible()
+ ).toBeVisible();
expect(
aboutElement.querySelector(
'.app-update-available-to-install .about-updates-version'
).textContent
- ).toBe('42.0.0')
+ ).toBe('42.0.0');
expect(
aboutElement.querySelector('.about-update-action-button').disabled
- ).toBe(false)
+ ).toBe(false);
expect(
aboutElement.querySelector('.about-update-action-button').textContent
- ).toBe('Restart and install')
- })
+ ).toBe('Restart and install');
+ });
it('opens the release notes for the downloaded release when the release notes link are clicked', async () => {
- MockUpdater.finishDownloadingUpdate('1.2.3')
- await scheduler.getNextUpdatePromise()
+ MockUpdater.finishDownloadingUpdate('1.2.3');
+ await scheduler.getNextUpdatePromise();
- spyOn(shell, 'openExternal')
+ spyOn(shell, 'openExternal');
let link = aboutElement.querySelector(
'.app-update-available-to-install .about-updates-release-notes'
- )
- link.click()
+ );
+ link.click();
- let args = shell.openExternal.mostRecentCall.args
- expect(shell.openExternal).toHaveBeenCalled()
- expect(args[0]).toContain('/v1.2.3')
- })
+ let args = shell.openExternal.mostRecentCall.args;
+ expect(shell.openExternal).toHaveBeenCalled();
+ expect(args[0]).toContain('/v1.2.3');
+ });
it('executes checkForUpdate() when the check for update button is clicked', () => {
- let button = aboutElement.querySelector('.about-update-action-button')
- button.click()
- expect(atom.autoUpdater.checkForUpdate).toHaveBeenCalled()
- })
+ let button = aboutElement.querySelector('.about-update-action-button');
+ button.click();
+ expect(atom.autoUpdater.checkForUpdate).toHaveBeenCalled();
+ });
it('executes restartAndInstallUpdate() when the restart and install button is clicked', async () => {
- spyOn(atom.autoUpdater, 'restartAndInstallUpdate')
- MockUpdater.finishDownloadingUpdate('42.0.0')
- await scheduler.getNextUpdatePromise()
+ spyOn(atom.autoUpdater, 'restartAndInstallUpdate');
+ MockUpdater.finishDownloadingUpdate('42.0.0');
+ await scheduler.getNextUpdatePromise();
- let button = aboutElement.querySelector('.about-update-action-button')
- button.click()
- expect(atom.autoUpdater.restartAndInstallUpdate).toHaveBeenCalled()
- })
+ let button = aboutElement.querySelector('.about-update-action-button');
+ button.click();
+ expect(atom.autoUpdater.restartAndInstallUpdate).toHaveBeenCalled();
+ });
it("starts in the same state as atom's AutoUpdateManager", async () => {
- atom.autoUpdater.getState.andReturn('downloading')
- updateManager.resetState()
+ atom.autoUpdater.getState.andReturn('downloading');
+ updateManager.resetState();
- await scheduler.getNextUpdatePromise()
+ await scheduler.getNextUpdatePromise();
expect(
aboutElement.querySelector('.app-checking-for-updates')
- ).not.toBeVisible()
+ ).not.toBeVisible();
expect(
aboutElement.querySelector('.app-downloading-update')
- ).toBeVisible()
+ ).toBeVisible();
expect(
aboutElement.querySelector('.about-update-action-button').disabled
- ).toBe(true)
+ ).toBe(true);
expect(
aboutElement.querySelector('.about-update-action-button').textContent
- ).toBe('Check now')
- })
+ ).toBe('Check now');
+ });
describe('when core.automaticallyUpdate is toggled', () => {
beforeEach(async () => {
- expect(atom.config.get('core.automaticallyUpdate')).toBe(true)
- atom.autoUpdater.checkForUpdate.reset()
- })
+ expect(atom.config.get('core.automaticallyUpdate')).toBe(true);
+ atom.autoUpdater.checkForUpdate.reset();
+ });
it('shows the auto update UI', async () => {
expect(
aboutElement.querySelector('.about-auto-updates input').checked
- ).toBe(true)
+ ).toBe(true);
expect(
aboutElement.querySelector('.about-default-update-message')
- ).toBeVisible()
+ ).toBeVisible();
expect(
aboutElement.querySelector('.about-default-update-message')
.textContent
- ).toBe('Atom will check for updates automatically')
+ ).toBe('Atom will check for updates automatically');
- atom.config.set('core.automaticallyUpdate', false)
- await scheduler.getNextUpdatePromise()
+ atom.config.set('core.automaticallyUpdate', false);
+ await scheduler.getNextUpdatePromise();
expect(
aboutElement.querySelector('.about-auto-updates input').checked
- ).toBe(false)
+ ).toBe(false);
expect(
aboutElement.querySelector('.about-default-update-message')
- ).toBeVisible()
+ ).toBeVisible();
expect(
aboutElement.querySelector('.about-default-update-message')
.textContent
- ).toBe('Automatic updates are disabled please check manually')
- })
+ ).toBe('Automatic updates are disabled please check manually');
+ });
it('updates config and the UI when the checkbox is used to toggle', async () => {
expect(
aboutElement.querySelector('.about-auto-updates input').checked
- ).toBe(true)
+ ).toBe(true);
- aboutElement.querySelector('.about-auto-updates input').click()
- await scheduler.getNextUpdatePromise()
+ aboutElement.querySelector('.about-auto-updates input').click();
+ await scheduler.getNextUpdatePromise();
- expect(atom.config.get('core.automaticallyUpdate')).toBe(false)
+ expect(atom.config.get('core.automaticallyUpdate')).toBe(false);
expect(
aboutElement.querySelector('.about-auto-updates input').checked
- ).toBe(false)
+ ).toBe(false);
expect(
aboutElement.querySelector('.about-default-update-message')
- ).toBeVisible()
+ ).toBeVisible();
expect(
aboutElement.querySelector('.about-default-update-message')
.textContent
- ).toBe('Automatic updates are disabled please check manually')
+ ).toBe('Automatic updates are disabled please check manually');
- aboutElement.querySelector('.about-auto-updates input').click()
- await scheduler.getNextUpdatePromise()
+ aboutElement.querySelector('.about-auto-updates input').click();
+ await scheduler.getNextUpdatePromise();
- expect(atom.config.get('core.automaticallyUpdate')).toBe(true)
+ expect(atom.config.get('core.automaticallyUpdate')).toBe(true);
expect(
aboutElement.querySelector('.about-auto-updates input').checked
- ).toBe(true)
+ ).toBe(true);
expect(
aboutElement.querySelector('.about-default-update-message')
- ).toBeVisible()
+ ).toBeVisible();
expect(
aboutElement.querySelector('.about-default-update-message')
.textContent
- ).toBe('Atom will check for updates automatically')
- })
+ ).toBe('Atom will check for updates automatically');
+ });
- describe('checking for updates', function () {
+ describe('checking for updates', function() {
afterEach(() => {
- this.updateView = null
- })
+ this.updateView = null;
+ });
it('checks for update when the about page is shown', () => {
- expect(atom.autoUpdater.checkForUpdate).not.toHaveBeenCalled()
+ expect(atom.autoUpdater.checkForUpdate).not.toHaveBeenCalled();
this.updateView = new UpdateView({
updateManager: updateManager,
availableVersion: '9999.0.0',
viewUpdateReleaseNotes: () => {}
- })
+ });
- expect(atom.autoUpdater.checkForUpdate).toHaveBeenCalled()
- })
+ expect(atom.autoUpdater.checkForUpdate).toHaveBeenCalled();
+ });
it('does not check for update when the about page is shown and the update manager is not in the idle state', () => {
- atom.autoUpdater.getState.andReturn('downloading')
- updateManager.resetState()
- expect(atom.autoUpdater.checkForUpdate).not.toHaveBeenCalled()
+ atom.autoUpdater.getState.andReturn('downloading');
+ updateManager.resetState();
+ expect(atom.autoUpdater.checkForUpdate).not.toHaveBeenCalled();
this.updateView = new UpdateView({
updateManager: updateManager,
availableVersion: '9999.0.0',
viewUpdateReleaseNotes: () => {}
- })
+ });
- expect(atom.autoUpdater.checkForUpdate).not.toHaveBeenCalled()
- })
+ expect(atom.autoUpdater.checkForUpdate).not.toHaveBeenCalled();
+ });
it('does not check for update when the about page is shown and auto updates are turned off', () => {
- atom.config.set('core.automaticallyUpdate', false)
- expect(atom.autoUpdater.checkForUpdate).not.toHaveBeenCalled()
+ atom.config.set('core.automaticallyUpdate', false);
+ expect(atom.autoUpdater.checkForUpdate).not.toHaveBeenCalled();
this.updateView = new UpdateView({
updateManager: updateManager,
availableVersion: '9999.0.0',
viewUpdateReleaseNotes: () => {}
- })
+ });
- expect(atom.autoUpdater.checkForUpdate).not.toHaveBeenCalled()
- })
- })
- })
- })
- })
+ expect(atom.autoUpdater.checkForUpdate).not.toHaveBeenCalled();
+ });
+ });
+ });
+ });
+ });
describe('when the About page is not open and an update is downloaded', () => {
it('should display the new version when it is opened', async () => {
- MockUpdater.finishDownloadingUpdate('42.0.0')
+ MockUpdater.finishDownloadingUpdate('42.0.0');
- jasmine.attachToDOM(workspaceElement)
- await atom.workspace.open('atom://about')
- aboutElement = workspaceElement.querySelector('.about')
- updateManager = main.model.state.updateManager
- scheduler = AboutView.getScheduler()
+ jasmine.attachToDOM(workspaceElement);
+ await atom.workspace.open('atom://about');
+ aboutElement = workspaceElement.querySelector('.about');
+ updateManager = main.model.state.updateManager;
+ scheduler = AboutView.getScheduler();
expect(
aboutElement.querySelector('.app-update-available-to-install')
- ).toBeVisible()
+ ).toBeVisible();
expect(
aboutElement.querySelector(
'.app-update-available-to-install .about-updates-version'
).textContent
- ).toBe('42.0.0')
+ ).toBe('42.0.0');
expect(
aboutElement.querySelector('.about-update-action-button').disabled
- ).toBe(false)
+ ).toBe(false);
expect(
aboutElement.querySelector('.about-update-action-button').textContent
- ).toBe('Restart and install')
- })
- })
-})
+ ).toBe('Restart and install');
+ });
+ });
+});
diff --git a/packages/dalek/lib/dalek.js b/packages/dalek/lib/dalek.js
index 3f1944a0c35..3355365171c 100644
--- a/packages/dalek/lib/dalek.js
+++ b/packages/dalek/lib/dalek.js
@@ -1,56 +1,56 @@
/** @babel */
-const fs = require('fs')
-const path = require('path')
+const fs = require('fs');
+const path = require('path');
module.exports = {
- async enumerate () {
+ async enumerate() {
if (atom.inDevMode()) {
- return []
+ return [];
}
- const duplicatePackages = []
- const names = atom.packages.getAvailablePackageNames()
+ const duplicatePackages = [];
+ const names = atom.packages.getAvailablePackageNames();
for (let name of names) {
if (atom.packages.isBundledPackage(name)) {
const isDuplicatedPackage = await this.isInstalledAsCommunityPackage(
name
- )
+ );
if (isDuplicatedPackage) {
- duplicatePackages.push(name)
+ duplicatePackages.push(name);
}
}
}
- return duplicatePackages
+ return duplicatePackages;
},
- async isInstalledAsCommunityPackage (name) {
- const availablePackagePaths = atom.packages.getPackageDirPaths()
+ async isInstalledAsCommunityPackage(name) {
+ const availablePackagePaths = atom.packages.getPackageDirPaths();
for (let packagePath of availablePackagePaths) {
- const candidate = path.join(packagePath, name)
+ const candidate = path.join(packagePath, name);
if (fs.existsSync(candidate)) {
- const realPath = await this.realpath(candidate)
+ const realPath = await this.realpath(candidate);
if (realPath === candidate) {
- return true
+ return true;
}
}
}
- return false
+ return false;
},
- realpath (path) {
+ realpath(path) {
return new Promise((resolve, reject) => {
- fs.realpath(path, function (error, realpath) {
+ fs.realpath(path, function(error, realpath) {
if (error) {
- reject(error)
+ reject(error);
} else {
- resolve(realpath)
+ resolve(realpath);
}
- })
- })
+ });
+ });
}
-}
+};
diff --git a/packages/dalek/lib/main.js b/packages/dalek/lib/main.js
index 8ec35d9caad..db80204b80e 100644
--- a/packages/dalek/lib/main.js
+++ b/packages/dalek/lib/main.js
@@ -1,19 +1,19 @@
/** @babel */
-const dalek = require('./dalek')
-const Grim = require('grim')
+const dalek = require('./dalek');
+const Grim = require('grim');
module.exports = {
- activate () {
+ activate() {
atom.packages.onDidActivateInitialPackages(async () => {
- const duplicates = await dalek.enumerate()
+ const duplicates = await dalek.enumerate();
for (let i = 0; i < duplicates.length; i++) {
- const duplicate = duplicates[i]
+ const duplicate = duplicates[i];
Grim.deprecate(
`You have the core package "${duplicate}" installed as a community package. See https://github.com/atom/atom/blob/master/packages/dalek/README.md for how this causes problems and instructions on how to correct the situation.`,
{ packageName: duplicate }
- )
+ );
}
- })
+ });
}
-}
+};
diff --git a/packages/dalek/test/dalek.test.js b/packages/dalek/test/dalek.test.js
index ff1ba394c2c..ed4a7086f40 100644
--- a/packages/dalek/test/dalek.test.js
+++ b/packages/dalek/test/dalek.test.js
@@ -1,21 +1,21 @@
/** @babel */
-const assert = require('assert')
-const fs = require('fs')
-const sinon = require('sinon')
-const path = require('path')
+const assert = require('assert');
+const fs = require('fs');
+const sinon = require('sinon');
+const path = require('path');
-const dalek = require('../lib/dalek')
+const dalek = require('../lib/dalek');
-describe('dalek', function () {
- describe('enumerate', function () {
- let availablePackages = {}
- let realPaths = {}
- let bundledPackages = []
- let packageDirPaths = []
- let sandbox = null
+describe('dalek', function() {
+ describe('enumerate', function() {
+ let availablePackages = {};
+ let realPaths = {};
+ let bundledPackages = [];
+ let packageDirPaths = [];
+ let sandbox = null;
- beforeEach(function () {
+ beforeEach(function() {
availablePackages = {
'an-unduplicated-installed-package': path.join(
'Users',
@@ -36,66 +36,68 @@ describe('dalek', function () {
'node_modules',
'unduplicated-package'
)
- }
+ };
- atom.devMode = false
- bundledPackages = ['duplicated-package', 'unduplicated-package']
- packageDirPaths = [path.join('Users', 'username', '.atom', 'packages')]
- sandbox = sinon.sandbox.create()
+ atom.devMode = false;
+ bundledPackages = ['duplicated-package', 'unduplicated-package'];
+ packageDirPaths = [path.join('Users', 'username', '.atom', 'packages')];
+ sandbox = sinon.sandbox.create();
sandbox
.stub(dalek, 'realpath')
- .callsFake(filePath => Promise.resolve(realPaths[filePath] || filePath))
+ .callsFake(filePath =>
+ Promise.resolve(realPaths[filePath] || filePath)
+ );
sandbox.stub(atom.packages, 'isBundledPackage').callsFake(packageName => {
- return bundledPackages.includes(packageName)
- })
+ return bundledPackages.includes(packageName);
+ });
sandbox
.stub(atom.packages, 'getAvailablePackageNames')
- .callsFake(() => Object.keys(availablePackages))
+ .callsFake(() => Object.keys(availablePackages));
sandbox.stub(atom.packages, 'getPackageDirPaths').callsFake(() => {
- return packageDirPaths
- })
+ return packageDirPaths;
+ });
sandbox.stub(fs, 'existsSync').callsFake(candidate => {
return (
Object.values(availablePackages).includes(candidate) &&
!candidate.includes(atom.getLoadSettings().resourcePath)
- )
- })
- })
+ );
+ });
+ });
- afterEach(function () {
- sandbox.restore()
- })
+ afterEach(function() {
+ sandbox.restore();
+ });
- it('returns a list of duplicate names', async function () {
- assert.deepEqual(await dalek.enumerate(), ['duplicated-package'])
- })
+ it('returns a list of duplicate names', async function() {
+ assert.deepEqual(await dalek.enumerate(), ['duplicated-package']);
+ });
- describe('when in dev mode', function () {
- beforeEach(function () {
- atom.devMode = true
- })
+ describe('when in dev mode', function() {
+ beforeEach(function() {
+ atom.devMode = true;
+ });
- it('always returns an empty list', async function () {
- assert.deepEqual(await dalek.enumerate(), [])
- })
- })
+ it('always returns an empty list', async function() {
+ assert.deepEqual(await dalek.enumerate(), []);
+ });
+ });
- describe('when a package is symlinked into the package directory', async function () {
- beforeEach(function () {
- const realPath = path.join('Users', 'username', 'duplicated-package')
+ describe('when a package is symlinked into the package directory', async function() {
+ beforeEach(function() {
+ const realPath = path.join('Users', 'username', 'duplicated-package');
const packagePath = path.join(
'Users',
'username',
'.atom',
'packages',
'duplicated-package'
- )
- realPaths[packagePath] = realPath
- })
+ );
+ realPaths[packagePath] = realPath;
+ });
- it('is not included in the list of duplicate names', async function () {
- assert.deepEqual(await dalek.enumerate(), [])
- })
- })
- })
-})
+ it('is not included in the list of duplicate names', async function() {
+ assert.deepEqual(await dalek.enumerate(), []);
+ });
+ });
+ });
+});
diff --git a/packages/dalek/test/runner.js b/packages/dalek/test/runner.js
index 7b155fa6798..39083303a64 100644
--- a/packages/dalek/test/runner.js
+++ b/packages/dalek/test/runner.js
@@ -1,2 +1,2 @@
-const createRunner = require('atom-mocha-test-runner').createRunner
-module.exports = createRunner({ testSuffixes: ['test.js'] })
+const createRunner = require('atom-mocha-test-runner').createRunner;
+module.exports = createRunner({ testSuffixes: ['test.js'] });
diff --git a/packages/deprecation-cop/lib/deprecation-cop-view.js b/packages/deprecation-cop/lib/deprecation-cop-view.js
index 0531a263135..b26139b237c 100644
--- a/packages/deprecation-cop/lib/deprecation-cop-view.js
+++ b/packages/deprecation-cop/lib/deprecation-cop-view.js
@@ -1,88 +1,88 @@
/** @babel */
/** @jsx etch.dom */
-import _ from 'underscore-plus'
-import { CompositeDisposable } from 'atom'
-import etch from 'etch'
-import fs from 'fs-plus'
-import Grim from 'grim'
-import marked from 'marked'
-import path from 'path'
-import shell from 'shell'
+import _ from 'underscore-plus';
+import { CompositeDisposable } from 'atom';
+import etch from 'etch';
+import fs from 'fs-plus';
+import Grim from 'grim';
+import marked from 'marked';
+import path from 'path';
+import shell from 'shell';
export default class DeprecationCopView {
- constructor ({ uri }) {
- this.uri = uri
- this.subscriptions = new CompositeDisposable()
+ constructor({ uri }) {
+ this.uri = uri;
+ this.subscriptions = new CompositeDisposable();
this.subscriptions.add(
Grim.on('updated', () => {
- etch.update(this)
+ etch.update(this);
})
- )
+ );
// TODO: Remove conditional when the new StyleManager deprecation APIs reach stable.
if (atom.styles.onDidUpdateDeprecations) {
this.subscriptions.add(
atom.styles.onDidUpdateDeprecations(() => {
- etch.update(this)
+ etch.update(this);
})
- )
+ );
}
- etch.initialize(this)
+ etch.initialize(this);
this.subscriptions.add(
atom.commands.add(this.element, {
'core:move-up': () => {
- this.scrollUp()
+ this.scrollUp();
},
'core:move-down': () => {
- this.scrollDown()
+ this.scrollDown();
},
'core:page-up': () => {
- this.pageUp()
+ this.pageUp();
},
'core:page-down': () => {
- this.pageDown()
+ this.pageDown();
},
'core:move-to-top': () => {
- this.scrollToTop()
+ this.scrollToTop();
},
'core:move-to-bottom': () => {
- this.scrollToBottom()
+ this.scrollToBottom();
}
})
- )
+ );
}
- serialize () {
+ serialize() {
return {
deserializer: this.constructor.name,
uri: this.getURI(),
version: 1
- }
+ };
}
- destroy () {
- this.subscriptions.dispose()
- return etch.destroy(this)
+ destroy() {
+ this.subscriptions.dispose();
+ return etch.destroy(this);
}
- update () {
- return etch.update(this)
+ update() {
+ return etch.update(this);
}
- render () {
+ render() {
return (
{this.rebuildFailureOutputs.get(pack)}+ return
{this.rebuildFailureOutputs.get(pack)}; } else { - return '' + return ''; } } - renderIncompatibleModules (pack) { + renderIncompatibleModules(pack) { return (
No Details
' - } + }; - console.log(`Received request for macOS updates (version = ${req.query.version}), sending\n`, updateInfo) - res.json(updateInfo) + console.log( + `Received request for macOS updates (version = ${ + req.query.version + }), sending\n`, + updateInfo + ); + res.json(updateInfo); } else { - console.log(`Received request for macOS updates, sending 204 as Atom is up to date (version = ${req.query.version})`) - res.sendStatus(204) + console.log( + `Received request for macOS updates, sending 204 as Atom is up to date (version = ${ + req.query.version + })` + ); + res.sendStatus(204); } } -function getReleasesFile (fileName) { - return function (req, res) { - console.log(`Received request for ${fileName}, version: ${req.query.version}`) +function getReleasesFile(fileName) { + return function(req, res) { + console.log( + `Received request for ${fileName}, version: ${req.query.version}` + ); if (req.query.version) { - const versionMatch = (req.query.version || '').match(/-(beta|nightly)\d+$/) - const versionChannel = (versionMatch && versionMatch[1]) || 'stable' + const versionMatch = (req.query.version || '').match( + /-(beta|nightly)\d+$/ + ); + const versionChannel = (versionMatch && versionMatch[1]) || 'stable'; if (releaseChannel !== versionChannel) { - console.log(`Atom requested an update for version ${req.query.version} but the current release channel is ${releaseChannel}`) - res.sendStatus(404) - return + console.log( + `Atom requested an update for version ${ + req.query.version + } but the current release channel is ${releaseChannel}` + ); + res.sendStatus(404); + return; } } - res.sendFile(path.join(buildPath, fileName)) - } + res.sendFile(path.join(buildPath, fileName)); + }; } -function getNupkgFile (is64bit) { - return function (req, res) { - let nupkgFile = req.params.nupkg +function getNupkgFile(is64bit) { + return function(req, res) { + let nupkgFile = req.params.nupkg; if (is64bit) { - const nupkgMatch = nupkgFile.match(/atom-(.+)-(delta|full)\.nupkg/) + const nupkgMatch = nupkgFile.match(/atom-(.+)-(delta|full)\.nupkg/); if (nupkgMatch) { - nupkgFile = `atom-x64-${nupkgMatch[1]}-${nupkgMatch[2]}.nupkg` + nupkgFile = `atom-x64-${nupkgMatch[1]}-${nupkgMatch[2]}.nupkg`; } } - console.log(`Received request for ${req.params.nupkg}, sending ${nupkgFile}`) - res.sendFile(path.join(buildPath, nupkgFile)) - } + console.log( + `Received request for ${req.params.nupkg}, sending ${nupkgFile}` + ); + res.sendFile(path.join(buildPath, nupkgFile)); + }; } if (process.platform === 'darwin') { - app.get('/mac/atom-mac.zip', getMacZip) - app.get('/api/updates', getMacUpdates) + app.get('/mac/atom-mac.zip', getMacZip); + app.get('/api/updates', getMacUpdates); } else if (process.platform === 'win32') { - app.get('/api/updates/RELEASES', getReleasesFile('RELEASES')) - app.get('/api/updates/:nupkg', getNupkgFile()) - app.get('/api/updates-x64/RELEASES', getReleasesFile('RELEASES-x64')) - app.get('/api/updates-x64/:nupkg', getNupkgFile(true)) + app.get('/api/updates/RELEASES', getReleasesFile('RELEASES')); + app.get('/api/updates/:nupkg', getNupkgFile()); + app.get('/api/updates-x64/RELEASES', getReleasesFile('RELEASES-x64')); + app.get('/api/updates-x64/:nupkg', getNupkgFile(true)); } else { - console.log(`The current platform '${process.platform}' doesn't support Squirrel updates, exiting.`.red) - process.exit(1) + console.log( + `The current platform '${ + process.platform + }' doesn't support Squirrel updates, exiting.`.red + ); + process.exit(1); } app.listen(port, () => { - console.log(`Run Atom with ATOM_UPDATE_URL_PREFIX="http://localhost:${port}" set to test updates!\n`.yellow) -}) + console.log( + `Run Atom with ATOM_UPDATE_URL_PREFIX="http://localhost:${port}" set to test updates!\n` + .yellow + ); +}); diff --git a/script/vsts/get-release-version.js b/script/vsts/get-release-version.js index 61d284d961b..1db97aa0efb 100644 --- a/script/vsts/get-release-version.js +++ b/script/vsts/get-release-version.js @@ -1,60 +1,78 @@ -const path = require('path') -const request = require('request-promise-native') +const path = require('path'); +const request = require('request-promise-native'); -const repositoryRootPath = path.resolve(__dirname, '..', '..') -const appMetadata = require(path.join(repositoryRootPath, 'package.json')) +const repositoryRootPath = path.resolve(__dirname, '..', '..'); +const appMetadata = require(path.join(repositoryRootPath, 'package.json')); -const yargs = require('yargs') +const yargs = require('yargs'); const argv = yargs .usage('Usage: $0 [options]') .help('help') .describe('nightly', 'Indicates that a nightly version should be produced') - .wrap(yargs.terminalWidth()) - .argv + .wrap(yargs.terminalWidth()).argv; -async function getReleaseVersion () { - let releaseVersion = process.env.ATOM_RELEASE_VERSION || appMetadata.version +async function getReleaseVersion() { + let releaseVersion = process.env.ATOM_RELEASE_VERSION || appMetadata.version; if (argv.nightly) { const releases = await request({ url: 'https://api.github.com/repos/atom/atom-nightly-releases/releases', - headers: {'Accept': 'application/vnd.github.v3+json', 'User-Agent': 'Atom Release Build'}, + headers: { + Accept: 'application/vnd.github.v3+json', + 'User-Agent': 'Atom Release Build' + }, json: true - }) + }); - let releaseNumber = 0 - const baseVersion = appMetadata.version.split('-')[0] + let releaseNumber = 0; + const baseVersion = appMetadata.version.split('-')[0]; if (releases && releases.length > 0) { - const latestRelease = releases.find(r => !r.draft) - const versionMatch = latestRelease.tag_name.match(/^v?(\d+\.\d+\.\d+)-nightly(\d+)$/) + const latestRelease = releases.find(r => !r.draft); + const versionMatch = latestRelease.tag_name.match( + /^v?(\d+\.\d+\.\d+)-nightly(\d+)$/ + ); if (versionMatch && versionMatch[1] === baseVersion) { - releaseNumber = parseInt(versionMatch[2]) + 1 + releaseNumber = parseInt(versionMatch[2]) + 1; } } - releaseVersion = `${baseVersion}-nightly${releaseNumber}` + releaseVersion = `${baseVersion}-nightly${releaseNumber}`; } // Set our ReleaseVersion build variable and update VSTS' build number to // include the version. Writing these strings to stdout causes VSTS to set // the associated variables. - console.log(`##vso[task.setvariable variable=ReleaseVersion;isOutput=true]${releaseVersion}`) + console.log( + `##vso[task.setvariable variable=ReleaseVersion;isOutput=true]${releaseVersion}` + ); if (!process.env.SYSTEM_PULLREQUEST_PULLREQUESTNUMBER) { // Only set the build number on non-PR builds as it causes build errors when // non-admins send PRs to the repo - console.log(`##vso[build.updatebuildnumber]${releaseVersion}+${process.env.BUILD_BUILDID}`) + console.log( + `##vso[build.updatebuildnumber]${releaseVersion}+${ + process.env.BUILD_BUILDID + }` + ); } // Write out some variables that indicate whether artifacts should be uploaded - const buildBranch = process.env.BUILD_SOURCEBRANCHNAME - const isReleaseBranch = process.env.IS_RELEASE_BRANCH || argv.nightly || buildBranch.match(/\d\.\d+-releases/) !== null + const buildBranch = process.env.BUILD_SOURCEBRANCHNAME; + const isReleaseBranch = + process.env.IS_RELEASE_BRANCH || + argv.nightly || + buildBranch.match(/\d\.\d+-releases/) !== null; const isSignedZipBranch = !isReleaseBranch && (process.env.IS_SIGNED_ZIP_BRANCH || - buildBranch.startsWith('electron-') || - buildBranch === 'master' && !process.env.SYSTEM_PULLREQUEST_PULLREQUESTNUMBER) - console.log(`##vso[task.setvariable variable=IsReleaseBranch;isOutput=true]${isReleaseBranch}`) - console.log(`##vso[task.setvariable variable=IsSignedZipBranch;isOutput=true]${isSignedZipBranch}`) + buildBranch.startsWith('electron-') || + (buildBranch === 'master' && + !process.env.SYSTEM_PULLREQUEST_PULLREQUESTNUMBER)); + console.log( + `##vso[task.setvariable variable=IsReleaseBranch;isOutput=true]${isReleaseBranch}` + ); + console.log( + `##vso[task.setvariable variable=IsSignedZipBranch;isOutput=true]${isSignedZipBranch}` + ); } -getReleaseVersion() +getReleaseVersion(); diff --git a/script/vsts/lib/release-notes.js b/script/vsts/lib/release-notes.js index c7c9e7d419e..c76c23317d3 100644 --- a/script/vsts/lib/release-notes.js +++ b/script/vsts/lib/release-notes.js @@ -1,49 +1,59 @@ -const semver = require('semver') -const octokit = require('@octokit/rest')() -const changelog = require('pr-changelog') -const childProcess = require('child_process') +const semver = require('semver'); +const octokit = require('@octokit/rest')(); +const changelog = require('pr-changelog'); +const childProcess = require('child_process'); -module.exports.getRelease = async function (releaseVersion, githubToken) { +module.exports.getRelease = async function(releaseVersion, githubToken) { if (githubToken) { octokit.authenticate({ type: 'oauth', token: githubToken - }) + }); } - const releases = await octokit.repos.getReleases({owner: 'atom', repo: 'atom'}) - const release = releases.data.find(r => semver.eq(r.name, releaseVersion)) + const releases = await octokit.repos.getReleases({ + owner: 'atom', + repo: 'atom' + }); + const release = releases.data.find(r => semver.eq(r.name, releaseVersion)); return { exists: release !== undefined, isDraft: release && release.draft, releaseNotes: release ? release.body : undefined - } -} - -module.exports.generateForVersion = async function (releaseVersion, githubToken, oldReleaseNotes) { - let oldVersion = null - let oldVersionName = null - const parsedVersion = semver.parse(releaseVersion) - const newVersionBranch = getBranchForVersion(parsedVersion) + }; +}; + +module.exports.generateForVersion = async function( + releaseVersion, + githubToken, + oldReleaseNotes +) { + let oldVersion = null; + let oldVersionName = null; + const parsedVersion = semver.parse(releaseVersion); + const newVersionBranch = getBranchForVersion(parsedVersion); if (githubToken) { - changelog.setGithubAccessToken(githubToken) + changelog.setGithubAccessToken(githubToken); octokit.authenticate({ type: 'oauth', token: githubToken - }) + }); } if (parsedVersion.prerelease && parsedVersion.prerelease[0] === 'beta0') { // For beta0 releases, stable hasn't been released yet so compare against // the stable version's release branch - oldVersion = `${parsedVersion.major}.${parsedVersion.minor - 1}-releases` - oldVersionName = `v${parsedVersion.major}.${parsedVersion.minor - 1}.0` + oldVersion = `${parsedVersion.major}.${parsedVersion.minor - 1}-releases`; + oldVersionName = `v${parsedVersion.major}.${parsedVersion.minor - 1}.0`; } else { - let releases = await octokit.repos.getReleases({owner: 'atom', repo: 'atom'}) - oldVersion = 'v' + getPreviousRelease(releaseVersion, releases.data).name - oldVersionName = oldVersion + let releases = await octokit.repos.getReleases({ + owner: 'atom', + repo: 'atom' + }); + oldVersion = 'v' + getPreviousRelease(releaseVersion, releases.data).name; + oldVersionName = oldVersion; } const allChangesText = await changelog.getChangelog({ @@ -52,21 +62,27 @@ module.exports.generateForVersion = async function (releaseVersion, githubToken, fromTag: oldVersion, toTag: newVersionBranch, dependencyKey: 'packageDependencies', - changelogFormatter: function ({pullRequests, owner, repo, fromTag, toTag}) { - let prString = changelog.pullRequestsToString(pullRequests) - let title = repo + changelogFormatter: function({ + pullRequests, + owner, + repo, + fromTag, + toTag + }) { + let prString = changelog.pullRequestsToString(pullRequests); + let title = repo; if (repo === 'atom') { - title = 'Atom Core' - fromTag = oldVersionName - toTag = releaseVersion + title = 'Atom Core'; + fromTag = oldVersionName; + toTag = releaseVersion; } - return `### [${title}](https://github.com/${owner}/${repo})\n\n${fromTag}...${toTag}\n\n${prString}` + return `### [${title}](https://github.com/${owner}/${repo})\n\n${fromTag}...${toTag}\n\n${prString}`; } - }) + }); const writtenReleaseNotes = extractWrittenReleaseNotes(oldReleaseNotes) || - '**TODO**: Pull relevant changes here!' + '**TODO**: Pull relevant changes here!'; return `## Notable Changes\n ${writtenReleaseNotes}\n @@ -74,62 +90,78 @@ ${writtenReleaseNotes}\n