From 7bb08e39f3d67875e4e1b696b1bd6cc2cfa3e7e8 Mon Sep 17 00:00:00 2001 From: Wliu Date: Tue, 24 Jan 2017 23:41:30 -0500 Subject: [PATCH] :shirt: --- script/build | 5 ++--- script/lib/clean-dependencies.js | 6 +++--- script/lib/code-sign-on-mac.js | 3 ++- script/lib/copy-assets.js | 2 +- script/lib/create-rpm-package.js | 1 - script/lib/create-windows-installer.js | 2 +- script/lib/delete-msbuild-from-path.js | 8 ++++---- script/lib/generate-metadata.js | 6 +++--- script/lib/get-license-text.js | 2 +- script/lib/include-path-in-packaged-app.js | 4 ++-- script/lib/install-apm.js | 1 - script/lib/install-atom-dependencies.js | 3 +-- script/lib/install-script-dependencies.js | 1 - script/lib/prebuild-less-cache.js | 4 ++-- script/lib/transpile-babel-paths.js | 9 --------- script/lib/transpile-peg-js-paths.js | 2 +- script/test | 2 +- 17 files changed, 24 insertions(+), 37 deletions(-) diff --git a/script/build b/script/build index bee0c9514..0fccee6e6 100755 --- a/script/build +++ b/script/build @@ -14,7 +14,7 @@ const yargs = require('yargs') const argv = yargs .usage('Usage: $0 [options]') .help('help') - .describe('code-sign', 'Code-sign executables (macOS and Windows only)') + .describe('code-sign', 'Code-sign executables (macOS and Windows only)') .describe('create-windows-installer', 'Create installer (Windows only)') .describe('create-debian-package', 'Create .deb package (Linux only)') .describe('create-rpm-package', 'Create .rpm package (Linux only)') @@ -71,8 +71,7 @@ dumpSymbols() } else if (process.platform === 'win32') { if (argv.createWindowsInstaller) { return createWindowsInstaller(packagedAppPath, argv.codeSign).then(() => packagedAppPath) - } - else { + } else { console.log('Skipping creating installer. Specify the --create-windows-installer option to create a Squirrel-based Windows installer. Code-signing was skipped too.'.gray) } } else if (process.platform === 'linux') { diff --git a/script/lib/clean-dependencies.js b/script/lib/clean-dependencies.js index ac55fdcaa..72007cf04 100644 --- a/script/lib/clean-dependencies.js +++ b/script/lib/clean-dependencies.js @@ -9,14 +9,14 @@ module.exports = function () { const fs = require('fs-extra') const apmDependenciesPath = path.join(CONFIG.apmRootPath, 'node_modules') - console.log(`Cleaning ${apmDependenciesPath}`); + console.log(`Cleaning ${apmDependenciesPath}`) fs.removeSync(apmDependenciesPath) const atomDependenciesPath = path.join(CONFIG.repositoryRootPath, 'node_modules') - console.log(`Cleaning ${atomDependenciesPath}`); + console.log(`Cleaning ${atomDependenciesPath}`) fs.removeSync(atomDependenciesPath) const scriptDependenciesPath = path.join(CONFIG.scriptRootPath, 'node_modules') - console.log(`Cleaning ${scriptDependenciesPath}`); + console.log(`Cleaning ${scriptDependenciesPath}`) fs.removeSync(scriptDependenciesPath) } diff --git a/script/lib/code-sign-on-mac.js b/script/lib/code-sign-on-mac.js index 80d316566..7d70e2b6b 100644 --- a/script/lib/code-sign-on-mac.js +++ b/script/lib/code-sign-on-mac.js @@ -10,8 +10,9 @@ module.exports = function (packagedAppPath) { return } + // This declaration is outside of the try block because it is also used for the finally block + const certPath = path.join(os.tmpdir(), 'mac.p12') try { - const certPath = path.join(os.tmpdir(), 'mac.p12') downloadFileFromGithub(process.env.ATOM_MAC_CODE_SIGNING_CERT_DOWNLOAD_URL, certPath) console.log(`Unlocking keychain ${process.env.ATOM_MAC_CODE_SIGNING_KEYCHAIN}`) diff --git a/script/lib/copy-assets.js b/script/lib/copy-assets.js index 28357ee9a..d53515f4a 100644 --- a/script/lib/copy-assets.js +++ b/script/lib/copy-assets.js @@ -10,7 +10,7 @@ const glob = require('glob') const includePathInPackagedApp = require('./include-path-in-packaged-app') module.exports = function () { - console.log(`Copying assets to ${CONFIG.intermediateAppPath}`); + console.log(`Copying assets to ${CONFIG.intermediateAppPath}`) let srcPaths = [ path.join(CONFIG.repositoryRootPath, 'benchmarks', 'benchmark-runner.js'), path.join(CONFIG.repositoryRootPath, 'dot-atom'), diff --git a/script/lib/create-rpm-package.js b/script/lib/create-rpm-package.js index 1c54160fb..cecee0534 100644 --- a/script/lib/create-rpm-package.js +++ b/script/lib/create-rpm-package.js @@ -2,7 +2,6 @@ const assert = require('assert') const fs = require('fs-extra') -const os = require('os') const path = require('path') const spawnSync = require('./spawn-sync') const template = require('lodash.template') diff --git a/script/lib/create-windows-installer.js b/script/lib/create-windows-installer.js index 4b9e0f3a3..fbf3630a3 100644 --- a/script/lib/create-windows-installer.js +++ b/script/lib/create-windows-installer.js @@ -53,7 +53,7 @@ module.exports = function (packagedAppPath, codeSign) { } // Squirrel signs its own copy of the executables but we need them for the portable ZIP - const extractSignedExes = function() { + const extractSignedExes = function () { if (signing) { for (let nupkgPath of glob.sync(`${CONFIG.buildOutputPath}/*-full.nupkg`)) { if (nupkgPath.includes(CONFIG.appMetadata.version)) { diff --git a/script/lib/delete-msbuild-from-path.js b/script/lib/delete-msbuild-from-path.js index 43e7fbb48..54fa1c082 100644 --- a/script/lib/delete-msbuild-from-path.js +++ b/script/lib/delete-msbuild-from-path.js @@ -7,13 +7,13 @@ module.exports = function () { process.env['PATH'] = process.env['PATH'] .split(';') - .filter(function(p) { + .filter(function (p) { if (fs.existsSync(path.join(p, 'msbuild.exe'))) { console.log('Excluding "' + p + '" from PATH to avoid msbuild.exe mismatch that causes errors during module installation') - return false; + return false } else { - return true; + return true } }) - .join(';'); + .join(';') } diff --git a/script/lib/generate-metadata.js b/script/lib/generate-metadata.js index 89ef04f69..8b62db824 100644 --- a/script/lib/generate-metadata.js +++ b/script/lib/generate-metadata.js @@ -27,8 +27,8 @@ function buildBundledPackagesMetadata () { const packagePath = path.join(CONFIG.intermediateAppPath, 'node_modules', packageName) const packageMetadataPath = path.join(packagePath, 'package.json') const packageMetadata = JSON.parse(fs.readFileSync(packageMetadataPath, 'utf8')) - normalizePackageData(packageMetadata, () => { - throw new Error(`Invalid package metadata. ${metadata.name}: ${msg}`) + normalizePackageData(packageMetadata, (msg) => { + throw new Error(`Invalid package metadata. ${packageName}: ${msg}`) }, true) if (packageMetadata.repository && packageMetadata.repository.url && packageMetadata.repository.type === 'git') { packageMetadata.repository.url = packageMetadata.repository.url.replace(/^git\+/, '') @@ -118,7 +118,7 @@ function checkDeprecatedPackagesMetadata () { for (let packageName of Object.keys(deprecatedPackagesMetadata)) { const packageMetadata = deprecatedPackagesMetadata[packageName] if (packageMetadata.version && !semver.validRange(packageMetadata.version)) { - throw new Error(`Invalid range: ${version} (${name}).`) + throw new Error(`Invalid range: ${packageMetadata.version} (${packageName}).`) } } } diff --git a/script/lib/get-license-text.js b/script/lib/get-license-text.js index 0e3c156a6..5edc41550 100644 --- a/script/lib/get-license-text.js +++ b/script/lib/get-license-text.js @@ -20,7 +20,7 @@ module.exports = function () { 'with the following licenses:\n\n' for (let packageName of Object.keys(packagesLicenses).sort()) { const packageLicense = packagesLicenses[packageName] - text += "-------------------------------------------------------------------------\n\n" + text += '-------------------------------------------------------------------------\n\n' text += `Package: ${packageName}\n` text += `License: ${packageLicense.license}\n` if (packageLicense.source) { diff --git a/script/lib/include-path-in-packaged-app.js b/script/lib/include-path-in-packaged-app.js index 4dc397698..eedd014dd 100644 --- a/script/lib/include-path-in-packaged-app.js +++ b/script/lib/include-path-in-packaged-app.js @@ -77,7 +77,7 @@ const EXCLUDE_REGEXPS_SOURCES = [ // Ignore test and example folders 'node_modules' + escapeRegExp(path.sep) + '.*' + escapeRegExp(path.sep) + '_*te?sts?_*' + escapeRegExp(path.sep), - 'node_modules' + escapeRegExp(path.sep) + '.*' + escapeRegExp(path.sep) + 'examples?' + escapeRegExp(path.sep), + 'node_modules' + escapeRegExp(path.sep) + '.*' + escapeRegExp(path.sep) + 'examples?' + escapeRegExp(path.sep) ] // Ignore spec directories in all bundled packages @@ -95,5 +95,5 @@ const EXCLUDED_PATHS_REGEXP = new RegExp( ) function escapeRegExp (string) { - return string.replace(/[.?*+^$[\]\\(){}|-]/g, "\\$&") + return string.replace(/[.?*+^$[\]\\(){}|-]/g, '\\$&') } diff --git a/script/lib/install-apm.js b/script/lib/install-apm.js index 783f135c5..ce68b79a6 100644 --- a/script/lib/install-apm.js +++ b/script/lib/install-apm.js @@ -1,7 +1,6 @@ 'use strict' const childProcess = require('child_process') -const path = require('path') const CONFIG = require('../config') diff --git a/script/lib/install-atom-dependencies.js b/script/lib/install-atom-dependencies.js index 5c395a29b..837da77ee 100644 --- a/script/lib/install-atom-dependencies.js +++ b/script/lib/install-atom-dependencies.js @@ -1,7 +1,6 @@ 'use strict' const childProcess = require('child_process') -const path = require('path') const CONFIG = require('../config') @@ -11,7 +10,7 @@ module.exports = function () { installEnv.ATOM_RESOURCE_PATH = CONFIG.repositoryRootPath // Set our target (Electron) version so that node-pre-gyp can download the // proper binaries. - installEnv.npm_config_target = CONFIG.appMetadata.electronVersion; + installEnv.npm_config_target = CONFIG.appMetadata.electronVersion childProcess.execFileSync( CONFIG.getApmBinPath(), ['--loglevel=error', 'install'], diff --git a/script/lib/install-script-dependencies.js b/script/lib/install-script-dependencies.js index 02f9ffb88..5a36e69a6 100644 --- a/script/lib/install-script-dependencies.js +++ b/script/lib/install-script-dependencies.js @@ -1,7 +1,6 @@ 'use strict' const childProcess = require('child_process') -const path = require('path') const CONFIG = require('../config') diff --git a/script/lib/prebuild-less-cache.js b/script/lib/prebuild-less-cache.js index 1a1432fc9..5186d77e8 100644 --- a/script/lib/prebuild-less-cache.js +++ b/script/lib/prebuild-less-cache.js @@ -42,11 +42,11 @@ module.exports = function () { path.join(CONFIG.intermediateAppPath, 'node_modules', syntaxTheme, 'styles'), path.join(CONFIG.intermediateAppPath, 'node_modules', uiTheme, 'styles'), path.join(CONFIG.intermediateAppPath, 'static', 'variables'), - path.join(CONFIG.intermediateAppPath, 'static'), + path.join(CONFIG.intermediateAppPath, 'static') ] }) - function cacheCompiledCSS(lessFilePath, importFallbackVariables) { + function cacheCompiledCSS (lessFilePath, importFallbackVariables) { let lessSource = fs.readFileSync(lessFilePath, 'utf8') if (importFallbackVariables) { lessSource = FALLBACK_VARIABLE_IMPORTS + lessSource diff --git a/script/lib/transpile-babel-paths.js b/script/lib/transpile-babel-paths.js index 3c440a4bd..5c222f1a6 100644 --- a/script/lib/transpile-babel-paths.js +++ b/script/lib/transpile-babel-paths.js @@ -6,15 +6,6 @@ const glob = require('glob') const path = require('path') const CONFIG = require('../config') -const BABEL_OPTIONS = require('../../static/babelrc.json') -const BABEL_PREFIXES = [ - "'use babel'", - '"use babel"', - '/** @babel */', - '/* @flow */' -] -const PREFIX_LENGTH = Math.max.apply(null, BABEL_PREFIXES.map(prefix => prefix.length)) -const BUFFER = Buffer(PREFIX_LENGTH) module.exports = function () { console.log(`Transpiling Babel paths in ${CONFIG.intermediateAppPath}`) diff --git a/script/lib/transpile-peg-js-paths.js b/script/lib/transpile-peg-js-paths.js index b3b68ba59..eff24cf80 100644 --- a/script/lib/transpile-peg-js-paths.js +++ b/script/lib/transpile-peg-js-paths.js @@ -1,6 +1,6 @@ 'use strict' -const peg = require("pegjs") +const peg = require('pegjs') const fs = require('fs') const glob = require('glob') const path = require('path') diff --git a/script/test b/script/test index 2e159d09b..8acdae0cd 100755 --- a/script/test +++ b/script/test @@ -71,7 +71,7 @@ for (let packageName in CONFIG.appMetadata.packageDependencies) { console.log(`Executing ${packageName} tests`.bold.green) const cp = childProcess.spawn(executablePath, testArguments) let stderrOutput = '' - cp.stderr.on('data', data => stderrOutput += data) + cp.stderr.on('data', data => (stderrOutput += data)) cp.on('error', error => { callback(error) }) cp.on('close', exitCode => { if (exitCode !== 0) {