From e68a2b1eb9318b6f4d38ad83ed8f93976415f477 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 19 Jan 2018 09:33:26 +0100 Subject: [PATCH] Replace import and export keywords with `require` and `module.exports` --- exports/atom.js | 21 ++++++++++----------- src/atom-paths.js | 2 -- src/auto-update-manager.js | 7 +++---- src/buffered-node-process.js | 7 +++---- src/buffered-process.js | 13 ++++++------- src/clipboard.js | 9 ++++----- src/color.js | 5 ++--- src/deserializer-manager.js | 7 +++---- src/history-manager.js | 10 +++++----- src/initialize-benchmark-window.js | 12 +++++------- src/main-process/file-recovery-service.js | 13 ++++++------- src/main-process/win-shell.js | 6 ++---- src/native-watcher-registry.js | 2 -- src/null-grammar.js | 6 ++---- src/path-watcher.js | 2 -- src/reopen-project-list-view.js | 7 +++---- src/reopen-project-menu-manager.js | 9 ++++----- src/update-process-env.js | 8 +++----- src/workspace.js | 2 -- 19 files changed, 61 insertions(+), 87 deletions(-) diff --git a/exports/atom.js b/exports/atom.js index d7ca55909..359f0174e 100644 --- a/exports/atom.js +++ b/exports/atom.js @@ -1,13 +1,12 @@ -/** @babel */ - -import TextBuffer, {Point, Range} from 'text-buffer' -import {File, Directory} from 'pathwatcher' -import {Emitter, Disposable, CompositeDisposable} from 'event-kit' -import BufferedNodeProcess from '../src/buffered-node-process' -import BufferedProcess from '../src/buffered-process' -import GitRepository from '../src/git-repository' -import Notification from '../src/notification' -import {watchPath} from '../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, @@ -42,4 +41,4 @@ if (process.type === 'renderer') { atomExport.TextEditor = require('../src/text-editor') } -export default atomExport +module.exports = atomExport diff --git a/src/atom-paths.js b/src/atom-paths.js index 39a768e91..d36ac25f5 100644 --- a/src/atom-paths.js +++ b/src/atom-paths.js @@ -1,5 +1,3 @@ -/** @babel */ - const fs = require('fs-plus') const path = require('path') diff --git a/src/auto-update-manager.js b/src/auto-update-manager.js index 111147f32..5e3a80129 100644 --- a/src/auto-update-manager.js +++ b/src/auto-update-manager.js @@ -1,8 +1,7 @@ -'use babel' +const {Emitter, CompositeDisposable} = require('event-kit') -import {Emitter, CompositeDisposable} from 'event-kit' - -export default class AutoUpdateManager { +module.exports = +class AutoUpdateManager { constructor ({applicationDelegate}) { this.applicationDelegate = applicationDelegate this.subscriptions = new CompositeDisposable() diff --git a/src/buffered-node-process.js b/src/buffered-node-process.js index 86b0c5747..a33176e51 100644 --- a/src/buffered-node-process.js +++ b/src/buffered-node-process.js @@ -1,6 +1,4 @@ -/** @babel */ - -import BufferedProcess from './buffered-process' +const BufferedProcess = require('./buffered-process') // Extended: Like {BufferedProcess}, but accepts a Node script as the command // to run. @@ -12,7 +10,8 @@ import BufferedProcess from './buffered-process' // ```js // const {BufferedNodeProcess} = require('atom') // ``` -export default class BufferedNodeProcess extends BufferedProcess { +module.exports = +class BufferedNodeProcess extends BufferedProcess { // Public: Runs the given Node script by spawning a new child process. // diff --git a/src/buffered-process.js b/src/buffered-process.js index 339bf05c5..0a01671fa 100644 --- a/src/buffered-process.js +++ b/src/buffered-process.js @@ -1,9 +1,7 @@ -/** @babel */ - -import _ from 'underscore-plus' -import ChildProcess from 'child_process' -import {Emitter} from 'event-kit' -import path from 'path' +const _ = require('underscore-plus') +const ChildProcess = require('child_process') +const {Emitter} = require('event-kit') +const path = require('path') // Extended: A wrapper which provides standard error/output line buffering for // Node's ChildProcess. @@ -19,7 +17,8 @@ import path from 'path' // const exit = (code) => console.log("ps -ef exited with #{code}") // const process = new BufferedProcess({command, args, stdout, exit}) // ``` -export default class BufferedProcess { +module.exports = +class BufferedProcess { /* Section: Construction */ diff --git a/src/clipboard.js b/src/clipboard.js index 34f6b1f83..d36bb1018 100644 --- a/src/clipboard.js +++ b/src/clipboard.js @@ -1,7 +1,5 @@ -/** @babel */ - -import crypto from 'crypto' -import clipboard from './safe-clipboard' +const crypto = require('crypto') +const clipboard = require('./safe-clipboard') // Extended: Represents the clipboard used for copying and pasting in Atom. // @@ -14,7 +12,8 @@ import clipboard from './safe-clipboard' // // console.log(atom.clipboard.read()) # 'hello' // ``` -export default class Clipboard { +module.exports = +class Clipboard { constructor () { this.reset() } diff --git a/src/color.js b/src/color.js index 52f555076..c183fb3e5 100644 --- a/src/color.js +++ b/src/color.js @@ -1,10 +1,9 @@ -/** @babel */ - let ParsedColor = null // Essential: A simple color class returned from {Config::get} when the value // at the key path is of type 'color'. -export default class Color { +module.exports = +class Color { // Essential: Parse a {String} or {Object} into a {Color}. // // * `value` A {String} such as `'white'`, `#ff00ff`, or diff --git a/src/deserializer-manager.js b/src/deserializer-manager.js index a11acc319..72ed9485d 100644 --- a/src/deserializer-manager.js +++ b/src/deserializer-manager.js @@ -1,6 +1,4 @@ -/** @babel */ - -import {Disposable} from 'event-kit' +const {Disposable} = require('event-kit') // Extended: Manages the deserializers used for serialized state // @@ -21,7 +19,8 @@ import {Disposable} from 'event-kit' // serialize: -> // @state // ``` -export default class DeserializerManager { +module.exports = +class DeserializerManager { constructor (atomEnvironment) { this.atomEnvironment = atomEnvironment this.deserializers = {} diff --git a/src/history-manager.js b/src/history-manager.js index 306c11812..e4651d9d9 100644 --- a/src/history-manager.js +++ b/src/history-manager.js @@ -1,13 +1,11 @@ -/** @babel */ - -import {Emitter, CompositeDisposable} from 'event-kit' +const {Emitter, CompositeDisposable} = require('event-kit') // Extended: History manager for remembering which projects have been opened. // // An instance of this class is always available as the `atom.history` global. // // The project history is used to enable the 'Reopen Project' menu. -export class HistoryManager { +class HistoryManager { constructor ({project, commands, stateStore}) { this.stateStore = stateStore this.emitter = new Emitter() @@ -116,7 +114,7 @@ function arrayEquivalent (a, b) { return true } -export class HistoryProject { +class HistoryProject { constructor (paths, lastOpened) { this.paths = paths this.lastOpened = lastOpened || new Date() @@ -128,3 +126,5 @@ export class HistoryProject { set lastOpened (lastOpened) { this._lastOpened = lastOpened } get lastOpened () { return this._lastOpened } } + +module.exports = {HistoryManager, HistoryProject} diff --git a/src/initialize-benchmark-window.js b/src/initialize-benchmark-window.js index 7ba99c468..131785454 100644 --- a/src/initialize-benchmark-window.js +++ b/src/initialize-benchmark-window.js @@ -1,11 +1,9 @@ -/** @babel */ +const {remote} = require('electron') +const path = require('path') +const ipcHelpers = require('./ipc-helpers') +const util = require('util') -import {remote} from 'electron' -import path from 'path' -import ipcHelpers from './ipc-helpers' -import util from 'util' - -export default async function () { +module.exports = async function () { const getWindowLoadSettings = require('./get-window-load-settings') const {test, headless, resourcePath, benchmarkPaths} = getWindowLoadSettings() try { diff --git a/src/main-process/file-recovery-service.js b/src/main-process/file-recovery-service.js index f55e3f956..468c1803b 100644 --- a/src/main-process/file-recovery-service.js +++ b/src/main-process/file-recovery-service.js @@ -1,11 +1,10 @@ -'use babel' +const {dialog} = require('electron') +const crypto = require('crypto') +const Path = require('path') +const fs = require('fs-plus') -import {dialog} from 'electron' -import crypto from 'crypto' -import Path from 'path' -import fs from 'fs-plus' - -export default class FileRecoveryService { +module.exports = +class FileRecoveryService { constructor (recoveryDirectory) { this.recoveryDirectory = recoveryDirectory this.recoveryFilesByFilePath = new Map() diff --git a/src/main-process/win-shell.js b/src/main-process/win-shell.js index 9670936c7..dd694b9dd 100644 --- a/src/main-process/win-shell.js +++ b/src/main-process/win-shell.js @@ -1,7 +1,5 @@ -'use babel' - -import Registry from 'winreg' -import Path from 'path' +const Registry = require('winreg') +const Path = require('path') let exeName = Path.basename(process.execPath) let appPath = `\"${process.execPath}\"` diff --git a/src/native-watcher-registry.js b/src/native-watcher-registry.js index e63ac6cda..97f33e3fb 100644 --- a/src/native-watcher-registry.js +++ b/src/native-watcher-registry.js @@ -1,5 +1,3 @@ -/** @babel */ - const path = require('path') // Private: re-join the segments split from an absolute path to form another absolute path. diff --git a/src/null-grammar.js b/src/null-grammar.js index fe9c3889e..12cfbbe53 100644 --- a/src/null-grammar.js +++ b/src/null-grammar.js @@ -1,8 +1,6 @@ -/** @babel */ +const {Disposable} = require('event-kit') -import {Disposable} from 'event-kit' - -export default { +module.exports = { name: 'Null Grammar', scopeName: 'text.plain.null-grammar', scopeForId (id) { diff --git a/src/path-watcher.js b/src/path-watcher.js index d0ff90dd1..ff7e8fd56 100644 --- a/src/path-watcher.js +++ b/src/path-watcher.js @@ -1,5 +1,3 @@ -/** @babel */ - const fs = require('fs') const path = require('path') diff --git a/src/reopen-project-list-view.js b/src/reopen-project-list-view.js index f08ee725a..d59577684 100644 --- a/src/reopen-project-list-view.js +++ b/src/reopen-project-list-view.js @@ -1,8 +1,7 @@ -/** @babel */ +const SelectListView = require('atom-select-list') -import SelectListView from 'atom-select-list' - -export default class ReopenProjectListView { +module.exports = +class ReopenProjectListView { constructor (callback) { this.callback = callback this.selectListView = new SelectListView({ diff --git a/src/reopen-project-menu-manager.js b/src/reopen-project-menu-manager.js index 3f88e41f0..35564f705 100644 --- a/src/reopen-project-menu-manager.js +++ b/src/reopen-project-menu-manager.js @@ -1,9 +1,8 @@ -/** @babel */ +const {CompositeDisposable} = require('event-kit') +const path = require('path') -import {CompositeDisposable} from 'event-kit' -import path from 'path' - -export default class ReopenProjectMenuManager { +module.exports = +class ReopenProjectMenuManager { constructor ({menu, commands, history, config, open}) { this.menuManager = menu this.historyManager = history diff --git a/src/update-process-env.js b/src/update-process-env.js index 00bb13927..6dab00a7d 100644 --- a/src/update-process-env.js +++ b/src/update-process-env.js @@ -1,7 +1,5 @@ -/** @babel */ - -import fs from 'fs' -import childProcess from 'child_process' +const fs = require('fs') +const childProcess = require('child_process') const ENVIRONMENT_VARIABLES_TO_PRESERVE = new Set([ 'NODE_ENV', @@ -120,4 +118,4 @@ async function getEnvFromShell (env) { return result } -export default { updateProcessEnv, shouldGetEnvFromShell } +module.exports = {updateProcessEnv, shouldGetEnvFromShell} diff --git a/src/workspace.js b/src/workspace.js index 66e7f8ba5..de51651ec 100644 --- a/src/workspace.js +++ b/src/workspace.js @@ -1,5 +1,3 @@ -'use babel' - const _ = require('underscore-plus') const url = require('url') const path = require('path')