From e40c99e2830f51c47db7230b5d97da07ea40d6b1 Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Sat, 22 Jun 2019 13:10:59 +1000 Subject: [PATCH] src: implement standard.js linting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In addition: * moved module.exports to the bottom * no single-line if statements * no if statements without a { * const for requires * array declarations get spaces inside [ ] * 'use strict' in all .js files PR-URL: https://github.com/nodejs/node-gyp/pull/1794 Reviewed-By: Richard Lau Reviewed-By: Ben Noordhuis Reviewed-By: João Reis --- .eslintrc.yaml | 6 - .jshintrc | 7 - bin/node-gyp.js | 29 +-- lib/build.js | 56 +++--- lib/clean.js | 12 +- lib/configure.js | 294 ++++++++++++++++-------------- lib/find-node-directory.js | 52 +++--- lib/find-visualstudio.js | 26 ++- lib/install.js | 110 +++++------ lib/list.js | 17 +- lib/node-gyp.js | 147 ++++++++------- lib/process-release.js | 73 +++++--- lib/rebuild.js | 10 +- lib/remove.js | 20 +- lib/util.js | 18 +- package.json | 8 +- test/process-exec-sync.js | 52 +++--- test/simple-proxy.js | 22 ++- test/test-addon.js | 77 ++++---- test/test-configure-python.js | 30 ++- test/test-download.js | 37 ++-- test/test-find-accessible-sync.js | 22 +-- test/test-find-node-directory.js | 42 +++-- test/test-find-python.js | 184 ++++++++++--------- test/test-find-visualstudio.js | 2 +- test/test-install.js | 6 +- test/test-options.js | 14 +- test/test-process-release.js | 41 ++--- 28 files changed, 746 insertions(+), 668 deletions(-) delete mode 100644 .eslintrc.yaml delete mode 100644 .jshintrc diff --git a/.eslintrc.yaml b/.eslintrc.yaml deleted file mode 100644 index f808ce2d9a..0000000000 --- a/.eslintrc.yaml +++ /dev/null @@ -1,6 +0,0 @@ ---- - env: - node: true - es6: true - rules: - no-unused-vars: error diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index 4b8521dac0..0000000000 --- a/.jshintrc +++ /dev/null @@ -1,7 +0,0 @@ -{ - "asi": true, - "laxcomma": true, - "esversion": 6, - "node": true, - "strict": false -} diff --git a/bin/node-gyp.js b/bin/node-gyp.js index 8c9b6169bb..13f2d399f7 100755 --- a/bin/node-gyp.js +++ b/bin/node-gyp.js @@ -1,17 +1,19 @@ #!/usr/bin/env node +'use strict' + process.title = 'node-gyp' -var envPaths = require('env-paths') -var gyp = require('../') -var log = require('npmlog') -var os = require('os') +const envPaths = require('env-paths') +const gyp = require('../') +const log = require('npmlog') +const os = require('os') /** * Process and execute the selected commands. */ -var prog = gyp() +const prog = gyp() var completed = false prog.parseArgv(process.argv) prog.devDir = prog.opts.devdir @@ -24,8 +26,8 @@ if (prog.devDir) { } else { throw new Error( "node-gyp requires that the user's home directory is specified " + - "in either of the environmental variables HOME or USERPROFILE. " + - "Overide with: --devdir /path/to/.node-gyp") + 'in either of the environmental variables HOME or USERPROFILE. ' + + 'Overide with: --devdir /path/to/.node-gyp') } if (prog.todo.length === 0) { @@ -42,7 +44,6 @@ log.verbose('cli', process.argv) log.info('using', 'node-gyp@%s', prog.version) log.info('using', 'node@%s | %s | %s', process.versions.node, process.platform, process.arch) - /** * Change dir if -C/--directory was passed. */ @@ -84,7 +85,7 @@ function run () { log.error('not ok') return process.exit(1) } - if (command.name == 'list') { + if (command.name === 'list') { var versions = arguments[1] if (versions.length > 0) { versions.forEach(function (version) { @@ -122,7 +123,7 @@ function errorMessage () { var os = require('os') log.error('System', os.type() + ' ' + os.release()) log.error('command', process.argv - .map(JSON.stringify).join(' ')) + .map(JSON.stringify).join(' ')) log.error('cwd', process.cwd()) log.error('node -v', process.version) log.error('node-gyp -v', 'v' + prog.package.version) @@ -130,10 +131,10 @@ function errorMessage () { function issueMessage () { errorMessage() - log.error('', [ 'This is a bug in `node-gyp`.' - , 'Try to update node-gyp and file an Issue if it does not help:' - , ' ' - ].join('\n')) + log.error('', [ 'This is a bug in `node-gyp`.', + 'Try to update node-gyp and file an Issue if it does not help:', + ' ' + ].join('\n')) } // start running the given commands! diff --git a/lib/build.js b/lib/build.js index 783ab9c595..24cfe38de2 100644 --- a/lib/build.js +++ b/lib/build.js @@ -1,12 +1,11 @@ +'use strict' -module.exports = exports = build - -var fs = require('graceful-fs') - , path = require('path') - , glob = require('glob') - , log = require('npmlog') - , which = require('which') - , win = process.platform === 'win32' +const fs = require('graceful-fs') +const path = require('path') +const glob = require('glob') +const log = require('npmlog') +const which = require('which') +const win = process.platform === 'win32' exports.usage = 'Invokes `' + (win ? 'msbuild' : 'make') + '` and builds the module' @@ -17,18 +16,19 @@ function build (gyp, argv, callback) { } else if (process.platform.indexOf('bsd') !== -1) { platformMake = 'gmake' } else if (win && argv.length > 0) { - argv = argv.map(function(target) { + argv = argv.map(function (target) { return '/t:' + target }) } var makeCommand = gyp.opts.make || process.env.MAKE || platformMake - , command = win ? 'msbuild' : makeCommand - , jobs = gyp.opts.jobs || process.env.JOBS - , buildType - , config - , arch - , nodeDir + var command = win ? 'msbuild' : makeCommand + var jobs = gyp.opts.jobs || process.env.JOBS + var buildType + var config + var arch + var nodeDir + var guessedSolution loadConfigGypi() @@ -38,16 +38,17 @@ function build (gyp, argv, callback) { function loadConfigGypi () { var configPath = path.resolve('build', 'config.gypi') + fs.readFile(configPath, 'utf8', function (err, data) { if (err) { - if (err.code == 'ENOENT') { + if (err.code === 'ENOENT') { callback(new Error('You must run `node-gyp configure` first!')) } else { callback(err) } return } - config = JSON.parse(data.replace(/\#.+\n/, '')) + config = JSON.parse(data.replace(/#.+\n/, '')) // get the 'arch', 'buildType', and 'nodeDir' vars from the config buildType = config.target_defaults.default_configuration @@ -79,7 +80,9 @@ function build (gyp, argv, callback) { function findSolutionFile () { glob('build/*.sln', function (err, files) { - if (err) return callback(err) + if (err) { + return callback(err) + } if (files.length === 0) { return callback(new Error('Could not find *.sln file. Did you run "configure"?')) } @@ -124,9 +127,12 @@ function build (gyp, argv, callback) { function doBuild () { // Enable Verbose build var verbose = log.levels[log.level] <= log.levels.verbose + var j + if (!win && verbose) { argv.push('V=1') } + if (win && !verbose) { argv.push('/clp:Verbosity=minimal') } @@ -142,12 +148,12 @@ function build (gyp, argv, callback) { // Since there are many ways to state '32-bit Intel', default to it. // N.B. msbuild's Condition string equality tests are case-insensitive. var archLower = arch.toLowerCase() - var p = archLower === 'x64' ? 'x64' : - (archLower === 'arm' ? 'ARM' : - (archLower === 'arm64' ? 'ARM64' : 'Win32')) + var p = archLower === 'x64' ? 'x64' + : (archLower === 'arm' ? 'ARM' + : (archLower === 'arm64' ? 'ARM64' : 'Win32')) argv.push('/p:Configuration=' + buildType + ';Platform=' + p) if (jobs) { - var j = parseInt(jobs, 10) + j = parseInt(jobs, 10) if (!isNaN(j) && j > 0) { argv.push('/m:' + j) } else if (jobs.toUpperCase() === 'MAX') { @@ -160,7 +166,7 @@ function build (gyp, argv, callback) { argv.push('-C') argv.push('build') if (jobs) { - var j = parseInt(jobs, 10) + j = parseInt(jobs, 10) if (!isNaN(j) && j > 0) { argv.push('--jobs') argv.push(j) @@ -174,7 +180,7 @@ function build (gyp, argv, callback) { if (win) { // did the user specify their own .sln file? var hasSln = argv.some(function (arg) { - return path.extname(arg) == '.sln' + return path.extname(arg) === '.sln' }) if (!hasSln) { argv.unshift(gyp.opts.solution || guessedSolution) @@ -195,3 +201,5 @@ function build (gyp, argv, callback) { callback() } } + +module.exports = build diff --git a/lib/clean.js b/lib/clean.js index 8172e1c3d3..dbfa4dbb99 100644 --- a/lib/clean.js +++ b/lib/clean.js @@ -1,10 +1,7 @@ +'use strict' -module.exports = exports = clean - -exports.usage = 'Removes any generated build files and the "out" dir' - -var rm = require('rimraf') -var log = require('npmlog') +const rm = require('rimraf') +const log = require('npmlog') function clean (gyp, argv, callback) { // Remove the 'build' dir @@ -13,3 +10,6 @@ function clean (gyp, argv, callback) { log.verbose('clean', 'removing "%s" directory', buildDir) rm(buildDir, callback) } + +module.exports = clean +module.exports.usage = 'Removes any generated build files and the "out" dir' diff --git a/lib/configure.js b/lib/configure.js index c3a07d472d..530b9b6357 100644 --- a/lib/configure.js +++ b/lib/configure.js @@ -1,35 +1,29 @@ -module.exports = exports = configure -module.exports.test = { - PythonFinder: PythonFinder, - findAccessibleSync: findAccessibleSync, - findPython: findPython, -} - -var fs = require('graceful-fs') - , path = require('path') - , log = require('npmlog') - , os = require('os') - , semver = require('semver') - , mkdirp = require('mkdirp') - , cp = require('child_process') - , extend = require('util')._extend - , processRelease = require('./process-release') - , win = process.platform === 'win32' - , findNodeDirectory = require('./find-node-directory') - , msgFormat = require('util').format - , logWithPrefix = require('./util').logWithPrefix -if (win) +'use strict' + +const fs = require('graceful-fs') +const path = require('path') +const log = require('npmlog') +const os = require('os') +const semver = require('semver') +const mkdirp = require('mkdirp') +const cp = require('child_process') +const extend = require('util')._extend // eslint-disable-line +const processRelease = require('./process-release') +const win = process.platform === 'win32' +const findNodeDirectory = require('./find-node-directory') +const msgFormat = require('util').format +const logWithPrefix = require('./util').logWithPrefix +if (win) { var findVisualStudio = require('./find-visualstudio') - -exports.usage = 'Generates ' + (win ? 'MSVC project files' : 'a Makefile') + ' for the current module' +} function configure (gyp, argv, callback) { var python - , buildDir = path.resolve('build') - , configNames = [ 'config.gypi', 'common.gypi' ] - , configs = [] - , nodeDir - , release = processRelease(argv, gyp, process.version, process.release) + var buildDir = path.resolve('build') + var configNames = [ 'config.gypi', 'common.gypi' ] + var configs = [] + var nodeDir + var release = processRelease(argv, gyp, process.version, process.release) findPython(gyp.opts.python, function (err, found) { if (err) { @@ -67,10 +61,12 @@ function configure (gyp, argv, callback) { // If the tarball option is set, always remove and reinstall the headers // into devdir. Otherwise only install if they're not already there. - gyp.opts.ensure = gyp.opts.tarball ? false : true + gyp.opts.ensure = !gyp.opts.tarball gyp.commands.install([ release.version ], function (err) { - if (err) return callback(err) + if (err) { + return callback(err) + } log.verbose('get node dir', 'target node version installed:', release.versionDir) nodeDir = path.resolve(gyp.devDir, release.versionDir) createBuildDir() @@ -81,7 +77,9 @@ function configure (gyp, argv, callback) { function createBuildDir () { log.verbose('build dir', 'attempting to create "build" dir: %s', buildDir) mkdirp(buildDir, function (err, isNew) { - if (err) return callback(err) + if (err) { + return callback(err) + } log.verbose('build dir', '"build" dir needed to be created?', isNew) if (win) { findVisualStudio(release.semver, gyp.opts.msvs_version, @@ -93,7 +91,9 @@ function configure (gyp, argv, callback) { } function createConfigFile (err, vsInfo) { - if (err) return callback(err) + if (err) { + return callback(err) + } var configFilename = 'config.gypi' var configPath = path.resolve(buildDir, configFilename) @@ -101,14 +101,18 @@ function configure (gyp, argv, callback) { log.verbose('build/' + configFilename, 'creating config file') var config = process.config || {} - , defaults = config.target_defaults - , variables = config.variables + var defaults = config.target_defaults + var variables = config.variables // default "config.variables" - if (!variables) variables = config.variables = {} + if (!variables) { + variables = config.variables = {} + } // default "config.defaults" - if (!defaults) defaults = config.target_defaults = {} + if (!defaults) { + defaults = config.target_defaults = {} + } // don't inherit the "defaults" from node's `process.config` object. // doing so could cause problems in cases where the `node` executable was @@ -123,13 +127,14 @@ function configure (gyp, argv, callback) { if ('debug' in gyp.opts) { defaults.default_configuration = gyp.opts.debug ? 'Debug' : 'Release' } + if (!defaults.default_configuration) { defaults.default_configuration = 'Release' } // set the target_arch variable variables.target_arch = gyp.opts.arch || process.arch || 'ia32' - if (variables.target_arch == 'arm64') { + if (variables.target_arch === 'arm64') { defaults['msvs_configuration_platform'] = 'ARM64' } @@ -146,7 +151,7 @@ function configure (gyp, argv, callback) { if (vsInfo.sdk) { defaults['msvs_windows_target_platform_version'] = vsInfo.sdk } - if (variables.target_arch == 'arm64') { + if (variables.target_arch === 'arm64') { if (vsInfo.versionMajor > 15 || (vsInfo.versionMajor === 15 && vsInfo.versionMajor >= 9)) { defaults['msvs_enable_marmasm'] = 1 @@ -163,15 +168,20 @@ function configure (gyp, argv, callback) { // // $ node-gyp configure --shared-libxml2 Object.keys(gyp.opts).forEach(function (opt) { - if (opt === 'argv') return - if (opt in gyp.configDefs) return + if (opt === 'argv') { + return + } + if (opt in gyp.configDefs) { + return + } variables[opt.replace(/-/g, '_')] = gyp.opts[opt] }) // ensures that any boolean values from `process.config` get stringified function boolsToString (k, v) { - if (typeof v === 'boolean') + if (typeof v === 'boolean') { return String(v) + } return v } @@ -179,21 +189,28 @@ function configure (gyp, argv, callback) { // now write out the config.gypi file to the build/ dir var prefix = '# Do not edit. File was generated by node-gyp\'s "configure" step' - , json = JSON.stringify(config, boolsToString, 2) + + var json = JSON.stringify(config, boolsToString, 2) log.verbose('build/' + configFilename, 'writing out config file: %s', configPath) configs.push(configPath) - fs.writeFile(configPath, [prefix, json, ''].join('\n'), findConfigs) + fs.writeFile(configPath, [ prefix, json, '' ].join('\n'), findConfigs) } function findConfigs (err) { - if (err) return callback(err) + if (err) { + return callback(err) + } + var name = configNames.shift() - if (!name) return runGyp() + if (!name) { + return runGyp() + } var fullPath = path.resolve(name) + log.verbose(name, 'checking for gypi file: %s', fullPath) fs.stat(fullPath, function (err) { if (err) { - if (err.code == 'ENOENT') { + if (err.code === 'ENOENT') { findConfigs() // check next gypi filename } else { callback(err) @@ -207,7 +224,9 @@ function configure (gyp, argv, callback) { } function runGyp (err) { - if (err) return callback(err) + if (err) { + return callback(err) + } if (!~argv.indexOf('-f') && !~argv.indexOf('--format')) { if (win) { @@ -228,63 +247,68 @@ function configure (gyp, argv, callback) { // For AIX and z/OS we need to set up the path to the exports file // which contains the symbols needed for linking. - var node_exp_file = undefined + var nodeExpFile if (process.platform === 'aix' || process.platform === 'os390') { var ext = process.platform === 'aix' ? 'exp' : 'x' - var node_root_dir = findNodeDirectory() - var candidates = undefined + var nodeRootDir = findNodeDirectory() + var candidates + if (process.platform === 'aix') { - candidates = ['include/node/node', - 'out/Release/node', - 'out/Debug/node', - 'node' - ].map(function(file) { - return file + '.' + ext - }) + candidates = [ + 'include/node/node', + 'out/Release/node', + 'out/Debug/node', + 'node' + ].map(function (file) { + return file + '.' + ext + }) } else { - candidates = ['out/Release/obj.target/libnode', - 'out/Debug/obj.target/libnode', - 'lib/libnode' - ].map(function(file) { - return file + '.' + ext - }) + candidates = [ + 'out/Release/obj.target/libnode', + 'out/Debug/obj.target/libnode', + 'lib/libnode' + ].map(function (file) { + return file + '.' + ext + }) } + var logprefix = 'find exports file' - node_exp_file = findAccessibleSync(logprefix, node_root_dir, candidates) - if (node_exp_file !== undefined) { - log.verbose(logprefix, 'Found exports file: %s', node_exp_file) + nodeExpFile = findAccessibleSync(logprefix, nodeRootDir, candidates) + if (nodeExpFile !== undefined) { + log.verbose(logprefix, 'Found exports file: %s', nodeExpFile) } else { - var msg = msgFormat('Could not find node.%s file in %s', ext, node_root_dir) + var msg = msgFormat('Could not find node.%s file in %s', ext, nodeRootDir) log.error(logprefix, 'Could not find exports file') return callback(new Error(msg)) } } // this logic ported from the old `gyp_addon` python file - var gyp_script = path.resolve(__dirname, '..', 'gyp', 'gyp_main.py') - var addon_gypi = path.resolve(__dirname, '..', 'addon.gypi') - var common_gypi = path.resolve(nodeDir, 'include/node/common.gypi') - fs.stat(common_gypi, function (err) { - if (err) - common_gypi = path.resolve(nodeDir, 'common.gypi') - - var output_dir = 'build' + var gypScript = path.resolve(__dirname, '..', 'gyp', 'gyp_main.py') + var addonGypi = path.resolve(__dirname, '..', 'addon.gypi') + var commonGypi = path.resolve(nodeDir, 'include/node/common.gypi') + fs.stat(commonGypi, function (err) { + if (err) { + commonGypi = path.resolve(nodeDir, 'common.gypi') + } + + var outputDir = 'build' if (win) { // Windows expects an absolute path - output_dir = buildDir + outputDir = buildDir } var nodeGypDir = path.resolve(__dirname, '..') var nodeLibFile = path.join(nodeDir, !gyp.opts.nodedir ? '<(target_arch)' : '$(Configuration)', release.name + '.lib') - argv.push('-I', addon_gypi) - argv.push('-I', common_gypi) + argv.push('-I', addonGypi) + argv.push('-I', commonGypi) argv.push('-Dlibrary=shared_library') argv.push('-Dvisibility=default') argv.push('-Dnode_root_dir=' + nodeDir) if (process.platform === 'aix' || process.platform === 'os390') { - argv.push('-Dnode_exp_file=' + node_exp_file) + argv.push('-Dnode_exp_file=' + nodeExpFile) } argv.push('-Dnode_gyp_dir=' + nodeGypDir) argv.push('-Dnode_lib_file=' + nodeLibFile) @@ -295,7 +319,7 @@ function configure (gyp, argv, callback) { argv.push('--no-parallel') // tell gyp to write the Makefile/Solution files into output_dir - argv.push('--generator-output', output_dir) + argv.push('--generator-output', outputDir) // tell make to write its output into the same dir argv.push('-Goutput_dir=.') @@ -304,10 +328,10 @@ function configure (gyp, argv, callback) { argv.unshift('binding.gyp') // execute `gyp` from the current target nodedir - argv.unshift(gyp_script) + argv.unshift(gypScript) // make sure python uses files that came with this particular node package - var pypath = [path.join(__dirname, '..', 'gyp', 'pylib')] + var pypath = [ path.join(__dirname, '..', 'gyp', 'pylib') ] if (process.env.PYTHONPATH) { pypath.push(process.env.PYTHONPATH) } @@ -326,7 +350,6 @@ function configure (gyp, argv, callback) { callback() } } - } /** @@ -336,23 +359,23 @@ function configure (gyp, argv, callback) { */ function findAccessibleSync (logprefix, dir, candidates) { for (var next = 0; next < candidates.length; next++) { - var candidate = path.resolve(dir, candidates[next]) - try { - var fd = fs.openSync(candidate, 'r') - } catch (e) { - // this candidate was not found or not readable, do nothing - log.silly(logprefix, 'Could not open %s: %s', candidate, e.message) - continue - } - fs.closeSync(fd) - log.silly(logprefix, 'Found readable %s', candidate) - return candidate + var candidate = path.resolve(dir, candidates[next]) + try { + var fd = fs.openSync(candidate, 'r') + } catch (e) { + // this candidate was not found or not readable, do nothing + log.silly(logprefix, 'Could not open %s: %s', candidate, e.message) + continue + } + fs.closeSync(fd) + log.silly(logprefix, 'Found readable %s', candidate) + return candidate } return undefined } -function PythonFinder(configPython, callback) { +function PythonFinder (configPython, callback) { this.callback = callback this.configPython = configPython this.errorLog = [] @@ -360,8 +383,8 @@ function PythonFinder(configPython, callback) { PythonFinder.prototype = { log: logWithPrefix(log, 'find Python'), - argsExecutable: ['-c', 'import sys; print(sys.executable);'], - argsVersion: ['-c', 'import sys; print("%s.%s.%s" % sys.version_info[:3]);'], + argsExecutable: [ '-c', 'import sys; print(sys.executable);' ], + argsVersion: [ '-c', 'import sys; print("%s.%s.%s" % sys.version_info[:3]);' ], semverRange: '>=2.6.0 <3.0.0', // These can be overridden for testing: @@ -370,20 +393,19 @@ PythonFinder.prototype = { win: win, pyLauncher: 'py.exe', defaultLocation: path.join(process.env.SystemDrive || 'C:', 'Python27', - 'python.exe'), + 'python.exe'), // Logs a message at verbose level, but also saves it to be displayed later // at error level if an error occurs. This should help diagnose the problem. - addLog: function addLog(message) { + addLog: function addLog (message) { this.log.verbose(message) this.errorLog.push(message) }, - // Find Python by trying a sequence of possibilities. // Ignore errors, keep trying until Python is found. - findPython: function findPython() { - const SKIP=0, FAIL=1 + findPython: function findPython () { + const SKIP = 0; const FAIL = 1 const toCheck = [ { before: () => { @@ -398,7 +420,7 @@ PythonFinder.prototype = { `"${this.configPython}"`) }, check: this.checkCommand, - arg: this.configPython, + arg: this.configPython }, { before: () => { @@ -411,17 +433,17 @@ PythonFinder.prototype = { this.addLog(`- process.env.PYTHON is "${this.env.PYTHON}"`) }, check: this.checkCommand, - arg: this.env.PYTHON, + arg: this.env.PYTHON }, { before: () => { this.addLog('checking if "python2" can be used') }, check: this.checkCommand, - arg: 'python2', + arg: 'python2' }, { before: () => { this.addLog('checking if "python" can be used') }, check: this.checkCommand, - arg: 'python', + arg: 'python' }, { before: () => { @@ -432,7 +454,7 @@ PythonFinder.prototype = { this.addLog( 'checking if the py launcher can be used to find Python 2') }, - check: this.checkPyLauncher, + check: this.checkPyLauncher }, { before: () => { @@ -440,12 +462,12 @@ PythonFinder.prototype = { 'checking if Python 2 is installed in the default location') }, check: this.checkExecPath, - arg: this.defaultLocation, - }, + arg: this.defaultLocation + } ] - function runChecks(err) { - this.log.silly('runChecks: err = %j', err && err.stack || err) + function runChecks (err) { + this.log.silly('runChecks: err = %j', (err && err.stack) || err) const check = toCheck.shift() if (!check) { @@ -470,7 +492,6 @@ PythonFinder.prototype = { runChecks.apply(this) }, - // Check if command is a valid Python to use. // Will exit the Python finder on success. // If on Windows, run in a CMD shell to support BAT/CMD launchers. @@ -513,17 +534,17 @@ PythonFinder.prototype = { checkPyLauncher: function checkPyLauncher (errorCallback) { this.log.verbose( `- executing "${this.pyLauncher}" to get Python 2 executable path`) - this.run(this.pyLauncher, ['-2', ...this.argsExecutable], false, - function (err, execPath) { + this.run(this.pyLauncher, [ '-2', ...this.argsExecutable ], false, + function (err, execPath) { // Possible outcomes: same as checkCommand - if (err) { - this.addLog( - `- "${this.pyLauncher}" is not in PATH or produced an error`) - return errorCallback(err) - } - this.addLog(`- executable path is "${execPath}"`) - this.checkExecPath(execPath, errorCallback) - }.bind(this)) + if (err) { + this.addLog( + `- "${this.pyLauncher}" is not in PATH or produced an error`) + return errorCallback(err) + } + this.addLog(`- executable path is "${execPath}"`) + this.checkExecPath(execPath, errorCallback) + }.bind(this)) }, // Check if a Python executable is the correct version to use. @@ -565,7 +586,7 @@ PythonFinder.prototype = { }, // Run an executable or shell command, trimming the output. - run: function run(exec, args, shell, callback) { + run: function run (exec, args, shell, callback) { var env = extend({}, this.env) env.TERM = 'dumb' const opts = { env: env, shell: shell } @@ -580,8 +601,8 @@ PythonFinder.prototype = { return callback(err) } - function execFileCallback(err, stdout, stderr) { - this.log.silly('execFile result: err = %j', err && err.stack || err) + function execFileCallback (err, stdout, stderr) { + this.log.silly('execFile result: err = %j', (err && err.stack) || err) this.log.silly('execFile result: stdout = %j', stdout) this.log.silly('execFile result: stderr = %j', stderr) if (err) { @@ -592,17 +613,16 @@ PythonFinder.prototype = { } }, - - succeed: function succeed(execPath, version) { + succeed: function succeed (execPath, version) { this.log.info(`using Python version ${version} found at "${execPath}"`) process.nextTick(this.callback.bind(null, null, execPath)) }, - fail: function fail() { + fail: function fail () { const errorLog = this.errorLog.join('\n') - const pathExample = this.win ? 'C:\\Path\\To\\python.exe' : - '/path/to/pythonexecutable' + const pathExample = this.win ? 'C:\\Path\\To\\python.exe' + : '/path/to/pythonexecutable' // For Windows 80 col console, use up to the column before the one marked // with X (total 79 chars including logger prefix, 58 chars usable here): // X @@ -618,16 +638,24 @@ PythonFinder.prototype = { ` npm config set python "${pathExample}"`, 'For more information consult the documentation at:', 'https://github.com/nodejs/node-gyp#installation', - '**********************************************************', + '**********************************************************' ].join('\n') this.log.error(`\n${errorLog}\n\n${info}\n`) - process.nextTick(this.callback.bind(null, new Error ( + process.nextTick(this.callback.bind(null, new Error( 'Could not find any Python 2 installation to use'))) - }, + } } function findPython (configPython, callback) { var finder = new PythonFinder(configPython, callback) finder.findPython() } + +module.exports = configure +module.exports.test = { + PythonFinder: PythonFinder, + findAccessibleSync: findAccessibleSync, + findPython: findPython +} +module.exports.usage = 'Generates ' + (win ? 'MSVC project files' : 'a Makefile') + ' for the current module' diff --git a/lib/find-node-directory.js b/lib/find-node-directory.js index 524909581f..0dd781a6cf 100644 --- a/lib/find-node-directory.js +++ b/lib/find-node-directory.js @@ -1,7 +1,9 @@ -var path = require('path') - , log = require('npmlog') +'use strict' -module.exports = function findNodeDirectory(scriptLocation, processObj) { +const path = require('path') +const log = require('npmlog') + +function findNodeDirectory (scriptLocation, processObj) { // set dirname and process if not passed in // this facilitates regression tests if (scriptLocation === undefined) { @@ -12,48 +14,50 @@ module.exports = function findNodeDirectory(scriptLocation, processObj) { } // Have a look to see what is above us, to try and work out where we are - npm_parent_directory = path.join(scriptLocation, '../../../..') - log.verbose('node-gyp root', 'npm_parent_directory is ' - + path.basename(npm_parent_directory)) - node_root_dir = "" + var npmParentDirectory = path.join(scriptLocation, '../../../..') + log.verbose('node-gyp root', 'npm_parent_directory is ' + + path.basename(npmParentDirectory)) + var nodeRootDir = '' log.verbose('node-gyp root', 'Finding node root directory') - if (path.basename(npm_parent_directory) === 'deps') { + if (path.basename(npmParentDirectory) === 'deps') { // We are in a build directory where this script lives in // deps/npm/node_modules/node-gyp/lib - node_root_dir = path.join(npm_parent_directory, '..') - log.verbose('node-gyp root', 'in build directory, root = ' - + node_root_dir) - } else if (path.basename(npm_parent_directory) === 'node_modules') { + nodeRootDir = path.join(npmParentDirectory, '..') + log.verbose('node-gyp root', 'in build directory, root = ' + + nodeRootDir) + } else if (path.basename(npmParentDirectory) === 'node_modules') { // We are in a node install directory where this script lives in // lib/node_modules/npm/node_modules/node-gyp/lib or // node_modules/npm/node_modules/node-gyp/lib depending on the // platform if (processObj.platform === 'win32') { - node_root_dir = path.join(npm_parent_directory, '..') + nodeRootDir = path.join(npmParentDirectory, '..') } else { - node_root_dir = path.join(npm_parent_directory, '../..') + nodeRootDir = path.join(npmParentDirectory, '../..') } - log.verbose('node-gyp root', 'in install directory, root = ' - + node_root_dir) + log.verbose('node-gyp root', 'in install directory, root = ' + + nodeRootDir) } else { // We don't know where we are, try working it out from the location // of the node binary - var node_dir = path.dirname(processObj.execPath) - var directory_up = path.basename(node_dir) - if (directory_up === 'bin') { - node_root_dir = path.join(node_dir, '..') - } else if (directory_up === 'Release' || directory_up === 'Debug') { + var nodeDir = path.dirname(processObj.execPath) + var directoryUp = path.basename(nodeDir) + if (directoryUp === 'bin') { + nodeRootDir = path.join(nodeDir, '..') + } else if (directoryUp === 'Release' || directoryUp === 'Debug') { // If we are a recently built node, and the directory structure // is that of a repository. If we are on Windows then we only need // to go one level up, everything else, two if (processObj.platform === 'win32') { - node_root_dir = path.join(node_dir, '..') + nodeRootDir = path.join(nodeDir, '..') } else { - node_root_dir = path.join(node_dir, '../..') + nodeRootDir = path.join(nodeDir, '../..') } } // Else return the default blank, "". } - return node_root_dir + return nodeRootDir } + +module.exports = findNodeDirectory diff --git a/lib/find-visualstudio.js b/lib/find-visualstudio.js index bf47f4ce0a..6799b66ce0 100644 --- a/lib/find-visualstudio.js +++ b/lib/find-visualstudio.js @@ -1,8 +1,4 @@ -module.exports = exports = findVisualStudio -module.exports.test = { - VisualStudioFinder: VisualStudioFinder, - findVisualStudio: findVisualStudio -} +'use strict' const log = require('npmlog') const execFile = require('child_process').execFile @@ -132,9 +128,13 @@ VisualStudioFinder.prototype = { var ps = path.join(process.env.SystemRoot, 'System32', 'WindowsPowerShell', 'v1.0', 'powershell.exe') var csFile = path.join(__dirname, 'Find-VisualStudio.cs') - var psArgs = ['-ExecutionPolicy', 'Unrestricted', '-NoProfile', - '-Command', '&{Add-Type -Path \'' + csFile + '\';' + - '[VisualStudioConfiguration.Main]::PrintJson()}'] + var psArgs = [ + '-ExecutionPolicy', + 'Unrestricted', + '-NoProfile', + '-Command', + '&{Add-Type -Path \'' + csFile + '\';' + '[VisualStudioConfiguration.Main]::PrintJson()}' + ] this.log.silly('Running', ps, psArgs) var child = execFile(ps, psArgs, { encoding: 'utf8' }, @@ -188,7 +188,9 @@ VisualStudioFinder.prototype = { // Remove future versions or errors parsing version number vsInfo = vsInfo.filter((info) => { - if (info.versionYear) { return true } + if (info.versionYear) { + return true + } this.addLog(`unknown version "${info.version}" found at "${info.path}"`) return false }) @@ -415,3 +417,9 @@ VisualStudioFinder.prototype = { return true } } + +module.exports = findVisualStudio +module.exports.test = { + VisualStudioFinder: VisualStudioFinder, + findVisualStudio: findVisualStudio +} diff --git a/lib/install.js b/lib/install.js index 06353663db..6ac8519ef5 100644 --- a/lib/install.js +++ b/lib/install.js @@ -1,33 +1,25 @@ -module.exports = exports = function (gyp, argv, callback) { - return install(fs, gyp, argv, callback) -} - -module.exports.test = { - download: download, - install: install, - readCAFile: readCAFile, -} - -exports.usage = 'Install node development files for the specified node version.' - -var fs = require('graceful-fs') - , os = require('os') - , tar = require('tar') - , path = require('path') - , crypto = require('crypto') - , log = require('npmlog') - , semver = require('semver') - , request = require('request') - , mkdir = require('mkdirp') - , processRelease = require('./process-release') - , win = process.platform == 'win32' +'use strict' + +const fs = require('graceful-fs') +const os = require('os') +const tar = require('tar') +const path = require('path') +const crypto = require('crypto') +const log = require('npmlog') +const semver = require('semver') +const request = require('request') +const mkdir = require('mkdirp') +const processRelease = require('./process-release') +const win = process.platform === 'win32' function install (fs, gyp, argv, callback) { var release = processRelease(argv, gyp, process.version, process.release) // ensure no double-callbacks happen function cb (err) { - if (cb.done) return + if (cb.done) { + return + } cb.done = true if (err) { log.warn('install', 'got an error, rolling back install') @@ -76,10 +68,10 @@ function install (fs, gyp, argv, callback) { log.verbose('install', '--ensure was passed, so won\'t reinstall if already installed') fs.stat(devDir, function (err) { if (err) { - if (err.code == 'ENOENT') { + if (err.code === 'ENOENT') { log.verbose('install', 'version not already installed, continuing with install', release.version) go() - } else if (err.code == 'EACCES') { + } else if (err.code === 'EACCES') { eaccesFallback(err) } else { cb(err) @@ -89,7 +81,7 @@ function install (fs, gyp, argv, callback) { log.verbose('install', 'version is already installed, need to check "installVersion"') var installVersionFile = path.resolve(devDir, 'installVersion') fs.readFile(installVersionFile, 'ascii', function (err, ver) { - if (err && err.code != 'ENOENT') { + if (err && err.code !== 'ENOENT') { return cb(err) } var installVersion = parseInt(ver, 10) || 0 @@ -108,7 +100,7 @@ function install (fs, gyp, argv, callback) { go() } - function getContentSha(res, callback) { + function getContentSha (res, callback) { var shasum = crypto.createHash('sha256') res.on('data', function (chunk) { shasum.update(chunk) @@ -123,7 +115,7 @@ function install (fs, gyp, argv, callback) { // first create the dir for the node dev files mkdir(devDir, function (err, created) { if (err) { - if (err.code == 'EACCES') { + if (err.code === 'EACCES') { eaccesFallback(err) } else { cb(err) @@ -138,8 +130,7 @@ function install (fs, gyp, argv, callback) { // now download the node tarball var tarPath = gyp.opts.tarball var badDownload = false - , extractCount = 0 - + var extractCount = 0 var contentShasums = {} var expectShasums = {} @@ -213,7 +204,9 @@ function install (fs, gyp, argv, callback) { // invoked after the tarball has finished being extracted function afterTarball () { - if (badDownload) return + if (badDownload) { + return + } if (extractCount === 0) { return cb(new Error('There was a fatal problem while downloading/extracting the tarball')) } @@ -244,7 +237,9 @@ function install (fs, gyp, argv, callback) { } function deref (err) { - if (err) return cb(err) + if (err) { + return cb(err) + } async-- if (!async) { @@ -262,7 +257,7 @@ function install (fs, gyp, argv, callback) { } } - function downloadShasums(done) { + function downloadShasums (done) { log.verbose('check download content checksum, need to download `SHASUMS256.txt`...') log.verbose('checksum url', release.shasumsUrl) try { @@ -286,7 +281,9 @@ function install (fs, gyp, argv, callback) { var lines = Buffer.concat(chunks).toString().trim().split('\n') lines.forEach(function (line) { var items = line.trim().split(/\s+/) - if (items.length !== 2) return + if (items.length !== 2) { + return + } // 0035d18e2dcf9aad669b1c7c07319e17abfe3762 ./node-v0.11.4.tar.gz var name = items[1].replace(/^\.\//, '') @@ -313,7 +310,9 @@ function install (fs, gyp, argv, callback) { log.verbose(name, 'url', libUrl) mkdir(dir, function (err) { - if (err) return done(err) + if (err) { + return done(err) + } log.verbose('streaming', name, 'to:', targetLibPath) try { @@ -342,9 +341,7 @@ function install (fs, gyp, argv, callback) { }) }) } // downloadNodeLib() - }) // mkdir() - } // go() /** @@ -353,8 +350,8 @@ function install (fs, gyp, argv, callback) { function valid (file) { // header files - var extname = path.extname(file); - return extname === '.h' || extname === '.gypi'; + var extname = path.extname(file) + return extname === '.h' || extname === '.gypi' } /** @@ -368,28 +365,29 @@ function install (fs, gyp, argv, callback) { function eaccesFallback (err) { var noretry = '--node_gyp_internal_noretry' - if (-1 !== argv.indexOf(noretry)) return cb(err) + if (argv.indexOf(noretry) !== -1) { + return cb(err) + } var tmpdir = os.tmpdir() gyp.devDir = path.resolve(tmpdir, '.node-gyp') log.warn('EACCES', 'user "%s" does not have permission to access the dev dir "%s"', os.userInfo().username, devDir) log.warn('EACCES', 'attempting to reinstall using temporary dev dir "%s"', gyp.devDir) - if (process.cwd() == tmpdir) { + if (process.cwd() === tmpdir) { log.verbose('tmpdir == cwd', 'automatically will remove dev files after to save disk space') gyp.todo.push({ name: 'remove', args: argv }) } gyp.commands.install([noretry].concat(argv), cb) } - } function download (gyp, env, url) { log.http('GET', url) var requestOpts = { - uri: url - , headers: { - 'User-Agent': 'node-gyp v' + gyp.version + ' (node ' + process.version + ')' - } + uri: url, + headers: { + 'User-Agent': 'node-gyp v' + gyp.version + ' (node ' + process.version + ')' + } } var cafile = gyp.opts.cafile @@ -398,10 +396,10 @@ function download (gyp, env, url) { } // basic support for a proxy server - var proxyUrl = gyp.opts.proxy - || env.http_proxy - || env.HTTP_PROXY - || env.npm_config_proxy + var proxyUrl = gyp.opts.proxy || + env.http_proxy || + env.HTTP_PROXY || + env.npm_config_proxy if (proxyUrl) { if (/^https?:\/\//i.test(proxyUrl)) { log.verbose('download', 'using proxy url: "%s"', proxyUrl) @@ -426,3 +424,13 @@ function readCAFile (filename) { var re = /(-----BEGIN CERTIFICATE-----[\S\s]*?-----END CERTIFICATE-----)/g return ca.match(re) } + +module.exports = function (gyp, argv, callback) { + return install(fs, gyp, argv, callback) +} +module.exports.test = { + download: download, + install: install, + readCAFile: readCAFile +} +module.exports.usage = 'Install node development files for the specified node version.' diff --git a/lib/list.js b/lib/list.js index 90f6447180..3e5de28851 100644 --- a/lib/list.js +++ b/lib/list.js @@ -1,10 +1,7 @@ +'use strict' -module.exports = exports = list - -exports.usage = 'Prints a listing of the currently installed node development files' - -var fs = require('graceful-fs') - , log = require('npmlog') +const fs = require('graceful-fs') +const log = require('npmlog') function list (gyp, args, callback) { var devDir = gyp.devDir @@ -13,14 +10,18 @@ function list (gyp, args, callback) { fs.readdir(devDir, onreaddir) function onreaddir (err, versions) { - if (err && err.code != 'ENOENT') { + if (err && err.code !== 'ENOENT') { return callback(err) } + if (Array.isArray(versions)) { - versions = versions.filter(function (v) { return v != 'current' }) + versions = versions.filter(function (v) { return v !== 'current' }) } else { versions = [] } callback(null, versions) } } + +module.exports = list +exports.usage = 'Prints a listing of the currently installed node development files' diff --git a/lib/node-gyp.js b/lib/node-gyp.js index 21ed80f9ff..91880f9433 100644 --- a/lib/node-gyp.js +++ b/lib/node-gyp.js @@ -1,27 +1,26 @@ - -module.exports = exports = gyp - -var path = require('path') - , nopt = require('nopt') - , log = require('npmlog') - , child_process = require('child_process') - , EE = require('events').EventEmitter - , inherits = require('util').inherits - , commands = [ - // Module build commands - 'build' - , 'clean' - , 'configure' - , 'rebuild' - // Development Header File management commands - , 'install' - , 'list' - , 'remove' - ] - , aliases = { - 'ls': 'list' - , 'rm': 'remove' - } +'use strict' + +const path = require('path') +const nopt = require('nopt') +const log = require('npmlog') +const childProcess = require('child_process') +const EE = require('events').EventEmitter +const inherits = require('util').inherits +const commands = [ + // Module build commands + 'build', + 'clean', + 'configure', + 'rebuild', + // Development Header File management commands + 'install', + 'list', + 'remove' +] +const aliases = { + 'ls': 'list', + 'rm': 'remove' +} // differentiate node-gyp's logs from npm's log.heading = 'gyp' @@ -58,24 +57,24 @@ proto.package = require('../package.json') */ proto.configDefs = { - help: Boolean // everywhere - , arch: String // 'configure' - , cafile: String // 'install' - , debug: Boolean // 'build' - , directory: String // bin - , make: String // 'build' - , msvs_version: String // 'configure' - , ensure: Boolean // 'install' - , solution: String // 'build' (windows only) - , proxy: String // 'install' - , devdir: String // everywhere - , nodedir: String // 'configure' - , loglevel: String // everywhere - , python: String // 'configure' - , 'dist-url': String // 'install' - , 'tarball': String // 'install' - , jobs: String // 'build' - , thin: String // 'configure' + help: Boolean, // everywhere + arch: String, // 'configure' + cafile: String, // 'install' + debug: Boolean, // 'build' + directory: String, // bin + make: String, // 'build' + msvs_version: String, // 'configure' + ensure: Boolean, // 'install' + solution: String, // 'build' (windows only) + proxy: String, // 'install' + devdir: String, // everywhere + nodedir: String, // 'configure' + loglevel: String, // everywhere + python: String, // 'configure' + 'dist-url': String, // 'install' + 'tarball': String, // 'install' + jobs: String, // 'build' + thin: String // 'configure' } /** @@ -83,13 +82,13 @@ proto.configDefs = { */ proto.shorthands = { - release: '--no-debug' - , C: '--directory' - , debug: '--debug' - , j: '--jobs' - , silly: '--loglevel=silly' - , verbose: '--loglevel=verbose' - , silent: '--loglevel=silent' + release: '--no-debug', + C: '--directory', + debug: '--debug', + j: '--jobs', + silly: '--loglevel=silly', + verbose: '--loglevel=verbose', + silent: '--loglevel=silent' } /** @@ -134,18 +133,22 @@ proto.parseArgv = function parseOpts (argv) { } // support for inheriting config env variables from npm - var npm_config_prefix = 'npm_config_' + var npmConfigPrefix = 'npm_config_' Object.keys(process.env).forEach(function (name) { - if (name.indexOf(npm_config_prefix) !== 0) return + if (name.indexOf(npmConfigPrefix) !== 0) { + return + } var val = process.env[name] - if (name === npm_config_prefix + 'loglevel') { + if (name === npmConfigPrefix + 'loglevel') { log.level = val } else { // add the user-defined options to the config - name = name.substring(npm_config_prefix.length) + name = name.substring(npmConfigPrefix.length) // gyp@741b7f1 enters an infinite loop when it encounters // zero-length options so ensure those don't get through. - if (name) this.opts[name] = val + if (name) { + this.opts[name] = val + } } }, this) @@ -160,11 +163,13 @@ proto.parseArgv = function parseOpts (argv) { */ proto.spawn = function spawn (command, args, opts) { - if (!opts) opts = {} + if (!opts) { + opts = {} + } if (!opts.silent && !opts.stdio) { opts.stdio = [ 0, 1, 2 ] } - var cp = child_process.spawn(command, args, opts) + var cp = childProcess.spawn(command, args, opts) log.info('spawn', command) log.info('spawn args', args) return cp @@ -176,16 +181,16 @@ proto.spawn = function spawn (command, args, opts) { proto.usage = function usage () { var str = [ - '' - , ' Usage: node-gyp [options]' - , '' - , ' where is one of:' - , commands.map(function (c) { - return ' - ' + c + ' - ' + require('./' + c).usage - }).join('\n') - , '' - , 'node-gyp@' + this.version + ' ' + path.resolve(__dirname, '..') - , 'node@' + process.versions.node + '', + ' Usage: node-gyp [options]', + '', + ' where is one of:', + commands.map(function (c) { + return ' - ' + c + ' - ' + require('./' + c).usage + }).join('\n'), + '', + 'node-gyp@' + this.version + ' ' + path.resolve(__dirname, '..'), + 'node@' + process.versions.node ].join('\n') return str } @@ -195,8 +200,10 @@ proto.usage = function usage () { */ Object.defineProperty(proto, 'version', { - get: function () { - return this.package.version - } - , enumerable: true + get: function () { + return this.package.version + }, + enumerable: true }) + +module.exports = exports = gyp diff --git a/lib/process-release.js b/lib/process-release.js index 1be5be97ab..0acab061bd 100644 --- a/lib/process-release.js +++ b/lib/process-release.js @@ -1,30 +1,32 @@ -var semver = require('semver') - , url = require('url') - , path = require('path') - , log = require('npmlog') +'use strict' - // versions where -headers.tar.gz started shipping - , headersTarballRange = '>= 3.0.0 || ~0.12.10 || ~0.10.42' - , bitsre = /\/win-(x86|x64)\// - , bitsreV3 = /\/win-(x86|ia32|x64)\// // io.js v3.x.x shipped with "ia32" but should - // have been "x86" +const semver = require('semver') +const url = require('url') +const path = require('path') +const log = require('npmlog') + +// versions where -headers.tar.gz started shipping +const headersTarballRange = '>= 3.0.0 || ~0.12.10 || ~0.10.42' +const bitsre = /\/win-(x86|x64)\// +const bitsreV3 = /\/win-(x86|ia32|x64)\// // io.js v3.x.x shipped with "ia32" but should +// have been "x86" // Captures all the logic required to determine download URLs, local directory and // file names. Inputs come from command-line switches (--target, --dist-url), // `process.version` and `process.release` where it exists. function processRelease (argv, gyp, defaultVersion, defaultRelease) { var version = (semver.valid(argv[0]) && argv[0]) || gyp.opts.target || defaultVersion - , versionSemver = semver.parse(version) - , overrideDistUrl = gyp.opts['dist-url'] || gyp.opts.disturl - , isDefaultVersion - , isNamedForLegacyIojs - , name - , distBaseUrl - , baseUrl - , libUrl32 - , libUrl64 - , tarballUrl - , canGetHeaders + var versionSemver = semver.parse(version) + var overrideDistUrl = gyp.opts['dist-url'] || gyp.opts.disturl + var isDefaultVersion + var isNamedForLegacyIojs + var name + var distBaseUrl + var baseUrl + var libUrl32 + var libUrl64 + var tarballUrl + var canGetHeaders if (!versionSemver) { // not a valid semver string, nothing we can do @@ -37,8 +39,9 @@ function processRelease (argv, gyp, defaultVersion, defaultRelease) { isDefaultVersion = version === semver.parse(defaultVersion).version // can't use process.release if we're using --target=x.y.z - if (!isDefaultVersion) + if (!isDefaultVersion) { defaultRelease = null + } if (defaultRelease) { // v3 onward, has process.release @@ -56,16 +59,19 @@ function processRelease (argv, gyp, defaultVersion, defaultRelease) { } // check for the nvm.sh standard mirror env variables - if (!overrideDistUrl && process.env.NODEJS_ORG_MIRROR) + if (!overrideDistUrl && process.env.NODEJS_ORG_MIRROR) { overrideDistUrl = process.env.NODEJS_ORG_MIRROR + } - if (overrideDistUrl) + if (overrideDistUrl) { log.verbose('download', 'using dist-url', overrideDistUrl) + } - if (overrideDistUrl) + if (overrideDistUrl) { distBaseUrl = overrideDistUrl.replace(/\/+$/, '') - else + } else { distBaseUrl = 'https://nodejs.org/dist' + } distBaseUrl += '/v' + version + '/' // new style, based on process.release so we have a lot of the data we need @@ -97,8 +103,14 @@ function processRelease (argv, gyp, defaultVersion, defaultRelease) { tarballUrl: tarballUrl, shasumsUrl: url.resolve(baseUrl, 'SHASUMS256.txt'), versionDir: (name !== 'node' ? name + '-' : '') + version, - ia32: { libUrl: libUrl32, libPath: normalizePath(path.relative(url.parse(baseUrl).path, url.parse(libUrl32).path)) }, - x64: { libUrl: libUrl64, libPath: normalizePath(path.relative(url.parse(baseUrl).path, url.parse(libUrl64).path)) }, + ia32: { + libUrl: libUrl32, + libPath: normalizePath(path.relative(url.parse(baseUrl).path, url.parse(libUrl32).path)) + }, + x64: { + libUrl: libUrl64, + libPath: normalizePath(path.relative(url.parse(baseUrl).path, url.parse(libUrl64).path)) + } } } @@ -108,12 +120,13 @@ function normalizePath (p) { function resolveLibUrl (name, defaultUrl, arch, versionMajor) { var base = url.resolve(defaultUrl, './') - , hasLibUrl = bitsre.test(defaultUrl) || (versionMajor === 3 && bitsreV3.test(defaultUrl)) + var hasLibUrl = bitsre.test(defaultUrl) || (versionMajor === 3 && bitsreV3.test(defaultUrl)) if (!hasLibUrl) { // let's assume it's a baseUrl then - if (versionMajor >= 1) - return url.resolve(base, 'win-' + arch +'/' + name + '.lib') + if (versionMajor >= 1) { + return url.resolve(base, 'win-' + arch + '/' + name + '.lib') + } // prior to io.js@1.0.0 32-bit node.lib lives in /, 64-bit lives in /x64/ return url.resolve(base, (arch === 'x64' ? 'x64/' : '') + name + '.lib') } diff --git a/lib/rebuild.js b/lib/rebuild.js index dc8025a7b0..a1c5b27cbe 100644 --- a/lib/rebuild.js +++ b/lib/rebuild.js @@ -1,13 +1,13 @@ - -module.exports = exports = rebuild - -exports.usage = 'Runs "clean", "configure" and "build" all at once' +'use strict' function rebuild (gyp, argv, callback) { gyp.todo.push( - { name: 'clean', args: [] } + { name: 'clean', args: [] } , { name: 'configure', args: argv } , { name: 'build', args: [] } ) process.nextTick(callback) } + +module.exports = rebuild +module.exports.usage = 'Runs "clean", "configure" and "build" all at once' diff --git a/lib/remove.js b/lib/remove.js index 46a1a3d4c2..8c945e5659 100644 --- a/lib/remove.js +++ b/lib/remove.js @@ -1,13 +1,10 @@ +'use strict' -module.exports = exports = remove - -exports.usage = 'Removes the node development files for the specified version' - -var fs = require('fs') - , rm = require('rimraf') - , path = require('path') - , log = require('npmlog') - , semver = require('semver') +const fs = require('fs') +const rm = require('rimraf') +const path = require('path') +const log = require('npmlog') +const semver = require('semver') function remove (gyp, argv, callback) { var devDir = gyp.devDir @@ -33,7 +30,7 @@ function remove (gyp, argv, callback) { // first check if its even installed fs.stat(versionPath, function (err) { if (err) { - if (err.code == 'ENOENT') { + if (err.code === 'ENOENT') { callback(null, 'version was already uninstalled: ' + version) } else { callback(err) @@ -44,3 +41,6 @@ function remove (gyp, argv, callback) { rm(versionPath, callback) }) } + +module.exports = exports = remove +module.exports.usage = 'Removes the node development files for the specified version' diff --git a/lib/util.js b/lib/util.js index ac6a875354..3e23c628e6 100644 --- a/lib/util.js +++ b/lib/util.js @@ -1,23 +1,19 @@ -module.exports = { - logWithPrefix: logWithPrefix, - regGetValue: regGetValue, - regSearchKeys: regSearchKeys -} +'use strict' const log = require('npmlog') const execFile = require('child_process').execFile const path = require('path') function logWithPrefix (log, prefix) { - function setPrefix(logFunction) { - return (...args) => logFunction.apply(null, [prefix, ...args]) + function setPrefix (logFunction) { + return (...args) => logFunction.apply(null, [ prefix, ...args ]) // eslint-disable-line } return { silly: setPrefix(log.silly), verbose: setPrefix(log.verbose), info: setPrefix(log.info), warn: setPrefix(log.warn), - error: setPrefix(log.error), + error: setPrefix(log.error) } } @@ -60,3 +56,9 @@ function regSearchKeys (keys, value, addOpts, cb) { } search() } + +module.exports = { + logWithPrefix: logWithPrefix, + regGetValue: regGetValue, + regSearchKeys: regSearchKeys +} diff --git a/package.json b/package.json index dc416c331d..260ac9d959 100644 --- a/package.json +++ b/package.json @@ -38,16 +38,14 @@ "node": ">= 6.0.0" }, "devDependencies": { - "babel-eslint": "^8.2.5", "bindings": "~1.2.1", - "eslint": "^5.0.1", "nan": "^2.0.0", "require-inject": "~1.3.0", + "standard": "~12.0.1", "tap": "~12.7.0" }, "scripts": { - "lint": "eslint bin lib test", - "test": "npm run lint && tap test/test-*", - "test-ci": "npm run lint && tap -Rtap test/test-*" + "lint": "standard */*.js test/**/*.js", + "test": "npm run lint && tap test/test-*" } } diff --git a/test/process-exec-sync.js b/test/process-exec-sync.js index 13daf308a3..f786484027 100644 --- a/test/process-exec-sync.js +++ b/test/process-exec-sync.js @@ -1,15 +1,17 @@ 'use strict' -var fs = require('graceful-fs') -var child_process = require('child_process') +const fs = require('graceful-fs') +const childProcess = require('child_process') -if (!String.prototype.startsWith) { - String.prototype.startsWith = function(search, pos) { - return this.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search +function startsWith (str, search, pos) { + if (String.prototype.startsWith) { + return str.startsWith(search, pos) } + + return str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search } -function processExecSync(file, args, options) { +function processExecSync (file, args, options) { var child, error, timeout, tmpdir, command command = makeCommand(file, args) @@ -22,19 +24,19 @@ function processExecSync(file, args, options) { // init timeout timeout = Date.now() + options.timeout // init tmpdir - var os_temp_base = '/tmp' - var os = determine_os() - os_temp_base = '/tmp' + var osTempBase = '/tmp' + var os = determineOS() + osTempBase = '/tmp' if (process.env.TMP) { - os_temp_base = process.env.TMP + osTempBase = process.env.TMP } - if (os_temp_base[os_temp_base.length - 1] !== '/') { - os_temp_base += '/' + if (osTempBase[osTempBase.length - 1] !== '/') { + osTempBase += '/' } - tmpdir = os_temp_base + 'processExecSync.' + Date.now() + Math.random() + tmpdir = osTempBase + 'processExecSync.' + Date.now() + Math.random() fs.mkdirSync(tmpdir) // init command @@ -47,7 +49,7 @@ function processExecSync(file, args, options) { } // init child - child = child_process.exec(command, options) + child = childProcess.exec(command, options) var maxTry = 100000 // increases the test time by 6 seconds on win-2016-node-0.10 var tryCount = 0 @@ -65,7 +67,7 @@ function processExecSync(file, args, options) { } } - ['stdout', 'stderr', 'status'].forEach(function (file) { + [ 'stdout', 'stderr', 'status' ].forEach(function (file) { child[file] = fs.readFileSync(tmpdir + '/' + file, options.encoding) setTimeout(unlinkFile, 500, tmpdir + '/' + file) }) @@ -84,23 +86,23 @@ function processExecSync(file, args, options) { return child.stdout } -function makeCommand(file, args) { +function makeCommand (file, args) { var command, quote command = file if (args.length > 0) { - for(var i in args) { + for (var i in args) { command = command + ' ' if (args[i][0] === '-') { command = command + args[i] } else { if (!quote) { - command = command + '\"' + command = command + '"' quote = true } command = command + args[i] if (quote) { if (args.length === (parseInt(i) + 1)) { - command = command + '\"' + command = command + '"' } } } @@ -109,29 +111,29 @@ function makeCommand(file, args) { return command } -function determine_os() { +function determineOS () { var os = '' var tmpVar = '' if (process.env.OSTYPE) { tmpVar = process.env.OSTYPE - } else if (process.env.OS) { + } else if (process.env.OS) { tmpVar = process.env.OS } else { - //default is linux + // default is linux tmpVar = 'linux' } - if (tmpVar.startsWith('linux')) { + if (startsWith(tmpVar, 'linux')) { os = 'linux' } - if (tmpVar.startsWith('win')) { + if (startsWith(tmpVar, 'win')) { os = 'win' } return os } -function unlinkFile(file) { +function unlinkFile (file) { fs.unlinkSync(file) } diff --git a/test/simple-proxy.js b/test/simple-proxy.js index 8ac737a652..cb0dfcfec7 100644 --- a/test/simple-proxy.js +++ b/test/simple-proxy.js @@ -1,22 +1,26 @@ -var http = require('http') - , https = require('https') - , server = http.createServer(handler) - , port = +process.argv[2] - , prefix = process.argv[3] - , upstream = process.argv[4] - , calls = 0 +'use strict' + +const http = require('http') +const https = require('https') +const server = http.createServer(handler) +const port = +process.argv[2] +const prefix = process.argv[3] +const upstream = process.argv[4] +var calls = 0 server.listen(port) function handler (req, res) { - if (req.url.indexOf(prefix) != 0) + if (req.url.indexOf(prefix) !== 0) { throw new Error('request url [' + req.url + '] does not start with [' + prefix + ']') + } var upstreamUrl = upstream + req.url.substring(prefix.length) https.get(upstreamUrl, function (ures) { ures.on('end', function () { - if (++calls == 2) + if (++calls === 2) { server.close() + } }) ures.pipe(res) }) diff --git a/test/test-addon.js b/test/test-addon.js index ce447bf365..49e30164c3 100644 --- a/test/test-addon.js +++ b/test/test-addon.js @@ -1,42 +1,42 @@ 'use strict' -var test = require('tap').test -var path = require('path') -var fs = require('graceful-fs') -var child_process = require('child_process') -var os = require('os') -var addonPath = path.resolve(__dirname, 'node_modules', 'hello_world') -var nodeGyp = path.resolve(__dirname, '..', 'bin', 'node-gyp.js') -var execFileSync = child_process.execFileSync || require('./process-exec-sync') -var execFile = child_process.execFile - -function runHello(hostProcess) { +const test = require('tap').test +const path = require('path') +const fs = require('graceful-fs') +const childProcess = require('child_process') +const os = require('os') +const addonPath = path.resolve(__dirname, 'node_modules', 'hello_world') +const nodeGyp = path.resolve(__dirname, '..', 'bin', 'node-gyp.js') +const execFileSync = childProcess.execFileSync || require('./process-exec-sync') +const execFile = childProcess.execFile + +function runHello (hostProcess) { if (!hostProcess) { hostProcess = process.execPath } var testCode = "console.log(require('hello_world').hello())" - return execFileSync(hostProcess, ['-e', testCode], { cwd: __dirname }).toString() + return execFileSync(hostProcess, [ '-e', testCode ], { cwd: __dirname }).toString() } -function runDuplicateBindings() { - const hostProcess = process.execPath; +function runDuplicateBindings () { + const hostProcess = process.execPath var testCode = - "console.log((function(bindings) {" + - "return bindings.pointerCheck1(bindings.pointerCheck2());" + + 'console.log((function(bindings) {' + + 'return bindings.pointerCheck1(bindings.pointerCheck2());' + "})(require('duplicate_symbols')))" - return execFileSync(hostProcess, ['-e', testCode], { cwd: __dirname }).toString() + return execFileSync(hostProcess, [ '-e', testCode ], { cwd: __dirname }).toString() } -function getEncoding() { +function getEncoding () { var code = 'import locale;print(locale.getdefaultlocale()[1])' - return execFileSync('python', ['-c', code]).toString().trim() + return execFileSync('python', [ '-c', code ]).toString().trim() } -function checkCharmapValid() { +function checkCharmapValid () { var data try { - data = execFileSync('python', ['fixtures/test-charmap.py'], - { cwd: __dirname }) + data = execFileSync('python', [ 'fixtures/test-charmap.py' ], + { cwd: __dirname }) } catch (err) { return false } @@ -48,10 +48,10 @@ test('build simple addon', function (t) { t.plan(3) // Set the loglevel otherwise the output disappears when run via 'npm test' - var cmd = [nodeGyp, 'rebuild', '-C', addonPath, '--loglevel=verbose'] + var cmd = [ nodeGyp, 'rebuild', '-C', addonPath, '--loglevel=verbose' ] var proc = execFile(process.execPath, cmd, function (err, stdout, stderr) { var logLines = stderr.toString().trim().split(/\r?\n/) - var lastLine = logLines[logLines.length-1] + var lastLine = logLines[logLines.length - 1] t.strictEqual(err, null) t.strictEqual(lastLine, 'gyp info ok', 'should end in ok') t.strictEqual(runHello().trim(), 'world') @@ -68,7 +68,7 @@ test('make sure addon symbols do not overlap', function (t) { var cmd = [nodeGyp, 'rebuild', '-C', addonPath, '--loglevel=verbose'] execFile(process.execPath, cmd, function (err, stdout, stderr) { var logLines = stderr.trim().split(/\r?\n/) - var lastLine = logLines[logLines.length-1] + var lastLine = logLines[logLines.length - 1] t.strictEqual(err, null) t.strictEqual(lastLine, 'gyp info ok', 'should end in ok') t.strictEqual(runDuplicateBindings().trim(), 'not equal') @@ -96,14 +96,15 @@ test('build simple addon in path with non-ascii characters', function (t) { t.plan(3) - var data, configPath = path.join(addonPath, 'build', 'config.gypi') + var data + var configPath = path.join(addonPath, 'build', 'config.gypi') try { data = fs.readFileSync(configPath, 'utf8') } catch (err) { t.error(err) return } - var config = JSON.parse(data.replace(/\#.+\n/, '')) + var config = JSON.parse(data.replace(/#.+\n/, '')) var nodeDir = config.variables.nodedir var testNodeDir = path.join(addonPath, testDirName) // Create symbol link to path with non-ascii characters @@ -121,8 +122,14 @@ test('build simple addon in path with non-ascii characters', function (t) { } } - var cmd = [nodeGyp, 'rebuild', '-C', addonPath, - '--loglevel=verbose', '-nodedir=' + testNodeDir] + var cmd = [ + nodeGyp, + 'rebuild', + '-C', + addonPath, + '--loglevel=verbose', + '-nodedir=' + testNodeDir + ] var proc = execFile(process.execPath, cmd, function (err, stdout, stderr) { try { fs.unlink(testNodeDir) @@ -131,7 +138,7 @@ test('build simple addon in path with non-ascii characters', function (t) { } var logLines = stderr.toString().trim().split(/\r?\n/) - var lastLine = logLines[logLines.length-1] + var lastLine = logLines[logLines.length - 1] t.strictEqual(err, null) t.strictEqual(lastLine, 'gyp info ok', 'should end in ok') t.strictEqual(runHello().trim(), 'world') @@ -143,9 +150,9 @@ test('build simple addon in path with non-ascii characters', function (t) { test('addon works with renamed host executable', function (t) { // No `fs.copyFileSync` before node8. if (process.version.substr(1).split('.')[0] < 8) { - t.skip("skipping test for old node version"); - t.end(); - return; + t.skip('skipping test for old node version') + t.end() + return } t.plan(3) @@ -153,10 +160,10 @@ test('addon works with renamed host executable', function (t) { var notNodePath = path.join(os.tmpdir(), 'notnode' + path.extname(process.execPath)) fs.copyFileSync(process.execPath, notNodePath) - var cmd = [nodeGyp, 'rebuild', '-C', addonPath, '--loglevel=verbose'] + var cmd = [ nodeGyp, 'rebuild', '-C', addonPath, '--loglevel=verbose' ] var proc = execFile(process.execPath, cmd, function (err, stdout, stderr) { var logLines = stderr.toString().trim().split(/\r?\n/) - var lastLine = logLines[logLines.length-1] + var lastLine = logLines[logLines.length - 1] t.strictEqual(err, null) t.strictEqual(lastLine, 'gyp info ok', 'should end in ok') t.strictEqual(runHello(notNodePath).trim(), 'world') diff --git a/test/test-configure-python.js b/test/test-configure-python.js index 895e488ba8..41b8c70427 100644 --- a/test/test-configure-python.js +++ b/test/test-configure-python.js @@ -1,21 +1,21 @@ 'use strict' -var test = require('tap').test -var path = require('path') -var gyp = require('../lib/node-gyp') -var requireInject = require('require-inject') -var configure = requireInject('../lib/configure', { +const test = require('tap').test +const path = require('path') +const gyp = require('../lib/node-gyp') +const requireInject = require('require-inject') +const configure = requireInject('../lib/configure', { 'graceful-fs': { - 'openSync': function () { return 0; }, + 'openSync': function () { return 0 }, 'closeSync': function () { }, 'writeFile': function (file, data, cb) { cb() }, 'stat': function (file, cb) { cb(null, {}) } } }) -var EXPECTED_PYPATH = path.join(__dirname, '..', 'gyp', 'pylib') -var SEPARATOR = process.platform == 'win32' ? ';' : ':' -var SPAWN_RESULT = { on: function () { } } +const EXPECTED_PYPATH = path.join(__dirname, '..', 'gyp', 'pylib') +const SEPARATOR = process.platform === 'win32' ? ';' : ':' +const SPAWN_RESULT = { on: function () { } } require('npmlog').level = 'warn' @@ -42,11 +42,10 @@ test('configure PYTHONPATH with existing env of one dir', function (t) { var prog = gyp() prog.parseArgv([]) prog.spawn = function () { - - t.equal(process.env.PYTHONPATH, [EXPECTED_PYPATH, existingPath].join(SEPARATOR)) + t.equal(process.env.PYTHONPATH, [ EXPECTED_PYPATH, existingPath ].join(SEPARATOR)) var dirs = process.env.PYTHONPATH.split(SEPARATOR) - t.deepEqual(dirs, [EXPECTED_PYPATH, existingPath]) + t.deepEqual(dirs, [ EXPECTED_PYPATH, existingPath ]) return SPAWN_RESULT } @@ -58,17 +57,16 @@ test('configure PYTHONPATH with existing env of multiple dirs', function (t) { var pythonDir1 = path.join('a', 'b') var pythonDir2 = path.join('b', 'c') - var existingPath = [pythonDir1, pythonDir2].join(SEPARATOR) + var existingPath = [ pythonDir1, pythonDir2 ].join(SEPARATOR) process.env.PYTHONPATH = existingPath var prog = gyp() prog.parseArgv([]) prog.spawn = function () { - - t.equal(process.env.PYTHONPATH, [EXPECTED_PYPATH, existingPath].join(SEPARATOR)) + t.equal(process.env.PYTHONPATH, [ EXPECTED_PYPATH, existingPath ].join(SEPARATOR)) var dirs = process.env.PYTHONPATH.split(SEPARATOR) - t.deepEqual(dirs, [EXPECTED_PYPATH, pythonDir1, pythonDir2]) + t.deepEqual(dirs, [ EXPECTED_PYPATH, pythonDir1, pythonDir2 ]) return SPAWN_RESULT } diff --git a/test/test-download.js b/test/test-download.js index 52b881271a..dbffb20246 100644 --- a/test/test-download.js +++ b/test/test-download.js @@ -1,10 +1,11 @@ 'use strict' -var test = require('tap').test -var fs = require('fs') -var http = require('http') -var https = require('https') -var install = require('../lib/install') +const test = require('tap').test +const fs = require('fs') +const path = require('path') +const http = require('http') +const https = require('https') +const install = require('../lib/install') require('npmlog').level = 'warn' @@ -13,7 +14,7 @@ test('download over http', function (t) { var server = http.createServer(function (req, res) { t.strictEqual(req.headers['user-agent'], - 'node-gyp v42 (node ' + process.version + ')') + 'node-gyp v42 (node ' + process.version + ')') res.end('ok') server.close() }) @@ -23,17 +24,17 @@ test('download over http', function (t) { var port = this.address().port var gyp = { opts: {}, - version: '42', + version: '42' } var url = 'http://' + host + ':' + port var req = install.test.download(gyp, {}, url) req.on('response', function (res) { var body = '' res.setEncoding('utf8') - res.on('data', function(data) { + res.on('data', function (data) { body += data }) - res.on('end', function() { + res.on('end', function () { t.strictEqual(body, 'ok') }) }) @@ -43,17 +44,17 @@ test('download over http', function (t) { test('download over https with custom ca', function (t) { t.plan(3) - var cert = fs.readFileSync(__dirname + '/fixtures/server.crt', 'utf8') - var key = fs.readFileSync(__dirname + '/fixtures/server.key', 'utf8') + var cert = fs.readFileSync(path.join(__dirname, 'fixtures/server.crt'), 'utf8') + var key = fs.readFileSync(path.join(__dirname, 'fixtures/server.key'), 'utf8') - var cafile = __dirname + '/fixtures/ca.crt' + var cafile = path.join(__dirname, '/fixtures/ca.crt') var ca = install.test.readCAFile(cafile) t.strictEqual(ca.length, 1) var options = { ca: ca, cert: cert, key: key } var server = https.createServer(options, function (req, res) { t.strictEqual(req.headers['user-agent'], - 'node-gyp v42 (node ' + process.version + ')') + 'node-gyp v42 (node ' + process.version + ')') res.end('ok') server.close() }) @@ -67,17 +68,17 @@ test('download over https with custom ca', function (t) { var port = this.address().port var gyp = { opts: { cafile: cafile }, - version: '42', + version: '42' } var url = 'https://' + host + ':' + port var req = install.test.download(gyp, {}, url) req.on('response', function (res) { var body = '' res.setEncoding('utf8') - res.on('data', function(data) { + res.on('data', function (data) { body += data }) - res.on('end', function() { + res.on('end', function () { t.strictEqual(body, 'ok') }) }) @@ -87,7 +88,7 @@ test('download over https with custom ca', function (t) { test('download with missing cafile', function (t) { t.plan(1) var gyp = { - opts: { cafile: 'no.such.file' }, + opts: { cafile: 'no.such.file' } } try { install.test.download(gyp, {}, 'http://bad/') @@ -97,7 +98,7 @@ test('download with missing cafile', function (t) { }) test('check certificate splitting', function (t) { - var cas = install.test.readCAFile(__dirname + '/fixtures/ca-bundle.crt') + var cas = install.test.readCAFile(path.join(__dirname, 'fixtures/ca-bundle.crt')) t.plan(2) t.strictEqual(cas.length, 2) t.notStrictEqual(cas[0], cas[1]) diff --git a/test/test-find-accessible-sync.js b/test/test-find-accessible-sync.js index 15adec5379..32234f5389 100644 --- a/test/test-find-accessible-sync.js +++ b/test/test-find-accessible-sync.js @@ -1,13 +1,13 @@ 'use strict' -var test = require('tap').test -var path = require('path') -var requireInject = require('require-inject') -var configure = requireInject('../lib/configure', { +const test = require('tap').test +const path = require('path') +const requireInject = require('require-inject') +const configure = requireInject('../lib/configure', { 'graceful-fs': { 'closeSync': function () { return undefined }, 'openSync': function (path) { - if (readableFiles.some(function (f) { return f === path} )) { + if (readableFiles.some(function (f) { return f === path })) { return 0 } else { var error = new Error('ENOENT - not found') @@ -17,11 +17,11 @@ var configure = requireInject('../lib/configure', { } }) -var dir = path.sep + 'testdir' -var readableFile = 'readable_file' -var anotherReadableFile = 'another_readable_file' -var readableFileInDir = 'somedir' + path.sep + readableFile -var readableFiles = [ +const dir = path.sep + 'testdir' +const readableFile = 'readable_file' +const anotherReadableFile = 'another_readable_file' +const readableFileInDir = 'somedir' + path.sep + readableFile +const readableFiles = [ path.resolve(dir, readableFile), path.resolve(dir, anotherReadableFile), path.resolve(dir, readableFileInDir) @@ -59,7 +59,6 @@ test('find accessible - single item array, unreadable', function (t) { t.strictEqual(found, undefined) }) - test('find accessible - multi item array, no matches', function (t) { t.plan(1) @@ -68,7 +67,6 @@ test('find accessible - multi item array, no matches', function (t) { t.strictEqual(found, undefined) }) - test('find accessible - multi item array, single match', function (t) { t.plan(1) diff --git a/test/test-find-node-directory.js b/test/test-find-node-directory.js index 7cc680d1fa..767b6f6b37 100644 --- a/test/test-find-node-directory.js +++ b/test/test-find-node-directory.js @@ -1,8 +1,10 @@ -var test = require('tap').test -var path = require('path') -var findNodeDirectory = require('../lib/find-node-directory') +'use strict' -var platforms = ['darwin', 'freebsd', 'linux', 'sunos', 'win32', 'aix'] +const test = require('tap').test +const path = require('path') +const findNodeDirectory = require('../lib/find-node-directory') + +const platforms = [ 'darwin', 'freebsd', 'linux', 'sunos', 'win32', 'aix' ] // we should find the directory based on the directory // the script is running in and it should match the layout @@ -11,10 +13,10 @@ var platforms = ['darwin', 'freebsd', 'linux', 'sunos', 'win32', 'aix'] test('test find-node-directory - node install', function (t) { t.plan(platforms.length) for (var next = 0; next < platforms.length; next++) { - var processObj = {execPath: '/x/y/bin/node', platform: platforms[next]} + var processObj = { execPath: '/x/y/bin/node', platform: platforms[next] } t.equal( findNodeDirectory('/x/deps/npm/node_modules/node-gyp/lib', processObj), - path.join('/x')) + path.join('/x')) } }) @@ -26,15 +28,15 @@ test('test find-node-directory - node install', function (t) { test('test find-node-directory - node build', function (t) { t.plan(platforms.length) for (var next = 0; next < platforms.length; next++) { - var processObj = {execPath: '/x/y/bin/node', platform: platforms[next]} + var processObj = { execPath: '/x/y/bin/node', platform: platforms[next] } if (platforms[next] === 'win32') { t.equal( findNodeDirectory('/y/node_modules/npm/node_modules/node-gyp/lib', - processObj), path.join('/y')) + processObj), path.join('/y')) } else { t.equal( findNodeDirectory('/y/lib/node_modules/npm/node_modules/node-gyp/lib', - processObj), path.join('/y')) + processObj), path.join('/y')) } } }) @@ -44,7 +46,7 @@ test('test find-node-directory - node build', function (t) { test('test find-node-directory - node in bin directory', function (t) { t.plan(platforms.length) for (var next = 0; next < platforms.length; next++) { - var processObj = {execPath: '/x/y/bin/node', platform: platforms[next]} + var processObj = { execPath: '/x/y/bin/node', platform: platforms[next] } t.equal( findNodeDirectory('/nothere/npm/node_modules/node-gyp/lib', processObj), path.join('/x/y')) @@ -58,15 +60,15 @@ test('test find-node-directory - node in build release dir', function (t) { for (var next = 0; next < platforms.length; next++) { var processObj if (platforms[next] === 'win32') { - processObj = {execPath: '/x/y/Release/node', platform: platforms[next]} + processObj = { execPath: '/x/y/Release/node', platform: platforms[next] } } else { - processObj = {execPath: '/x/y/out/Release/node', - platform: platforms[next]} + processObj = { execPath: '/x/y/out/Release/node', + platform: platforms[next] } } t.equal( findNodeDirectory('/nothere/npm/node_modules/node-gyp/lib', processObj), - path.join('/x/y')) + path.join('/x/y')) } }) @@ -77,14 +79,14 @@ test('test find-node-directory - node in Debug release dir', function (t) { for (var next = 0; next < platforms.length; next++) { var processObj if (platforms[next] === 'win32') { - processObj = {execPath: '/a/b/Debug/node', platform: platforms[next]} + processObj = { execPath: '/a/b/Debug/node', platform: platforms[next] } } else { - processObj = {execPath: '/a/b/out/Debug/node', platform: platforms[next]} + processObj = { execPath: '/a/b/out/Debug/node', platform: platforms[next] } } t.equal( findNodeDirectory('/nothere/npm/node_modules/node-gyp/lib', processObj), - path.join('/a/b')) + path.join('/a/b')) } }) @@ -93,7 +95,7 @@ test('test find-node-directory - node in Debug release dir', function (t) { test('test find-node-directory - not found', function (t) { t.plan(platforms.length) for (var next = 0; next < platforms.length; next++) { - var processObj = {execPath: '/x/y/z/y', platform:next} + var processObj = { execPath: '/x/y/z/y', platform: next } t.equal(findNodeDirectory('/a/b/c/d', processObj), '') } }) @@ -107,9 +109,9 @@ test('test find-node-directory - not found', function (t) { test('test find-node-directory - node install', function (t) { t.plan(platforms.length) for (var next = 0; next < platforms.length; next++) { - var processObj = {execPath: '/x/y/bin/node', platform: platforms[next]} + var processObj = { execPath: '/x/y/bin/node', platform: platforms[next] } t.equal( findNodeDirectory('/x/y/z/a/b/c/deps/npm/node_modules/node-gyp/lib', - processObj), path.join('/x/y/z/a/b/c')) + processObj), path.join('/x/y/z/a/b/c')) } }) diff --git a/test/test-find-python.js b/test/test-find-python.js index fbb35c3d36..23dddc7bfb 100644 --- a/test/test-find-python.js +++ b/test/test-find-python.js @@ -1,9 +1,9 @@ 'use strict' -var test = require('tap').test -var configure = require('../lib/configure') -var execFile = require('child_process').execFile -var PythonFinder = configure.test.PythonFinder +const test = require('tap').test +const configure = require('../lib/configure') +const execFile = require('child_process').execFile +const PythonFinder = configure.test.PythonFinder require('npmlog').level = 'warn' @@ -22,8 +22,8 @@ test('find python', function (t) { }) }) -function poison(object, property) { - function fail() { +function poison (object, property) { + function fail () { console.error(Error(`Property ${property} should not have been accessed.`)) process.abort() } @@ -31,12 +31,14 @@ function poison(object, property) { configurable: false, enumerable: false, get: fail, - set: fail, + set: fail } Object.defineProperty(object, property, descriptor) } -function TestPythonFinder() { PythonFinder.apply(this, arguments) } +function TestPythonFinder () { + PythonFinder.apply(this, arguments) +} TestPythonFinder.prototype = Object.create(PythonFinder.prototype) // Silence npmlog - remove for debugging TestPythonFinder.prototype.log = { @@ -44,28 +46,28 @@ TestPythonFinder.prototype.log = { verbose: () => {}, info: () => {}, warn: () => {}, - error: () => {}, + error: () => {} } test('find python - python', function (t) { t.plan(6) var f = new TestPythonFinder('python', done) - f.execFile = function(program, args, opts, cb) { - f.execFile = function(program, args, opts, cb) { + f.execFile = function (program, args, opts, cb) { + f.execFile = function (program, args, opts, cb) { poison(f, 'execFile') t.strictEqual(program, '/path/python') t.ok(/sys\.version_info/.test(args[1])) cb(null, '2.7.15') } t.strictEqual(program, - process.platform === 'win32' ? '"python"' : 'python') + process.platform === 'win32' ? '"python"' : 'python') t.ok(/sys\.executable/.test(args[1])) cb(null, '/path/python') } f.findPython() - function done(err, python) { + function done (err, python) { t.strictEqual(err, null) t.strictEqual(python, '/path/python') } @@ -75,10 +77,10 @@ test('find python - python too old', function (t) { t.plan(2) var f = new TestPythonFinder(null, done) - f.execFile = function(program, args, opts, cb) { - if (/sys\.executable/.test(args[args.length-1])) { + f.execFile = function (program, args, opts, cb) { + if (/sys\.executable/.test(args[args.length - 1])) { cb(null, '/path/python') - } else if (/sys\.version_info/.test(args[args.length-1])) { + } else if (/sys\.version_info/.test(args[args.length - 1])) { cb(null, '2.3.4') } else { t.fail() @@ -86,7 +88,7 @@ test('find python - python too old', function (t) { } f.findPython() - function done(err) { + function done (err) { t.ok(/Could not find any Python/.test(err)) t.ok(/not supported/i.test(f.errorLog)) } @@ -96,10 +98,10 @@ test('find python - python too new', function (t) { t.plan(2) var f = new TestPythonFinder(null, done) - f.execFile = function(program, args, opts, cb) { - if (/sys\.executable/.test(args[args.length-1])) { + f.execFile = function (program, args, opts, cb) { + if (/sys\.executable/.test(args[args.length - 1])) { cb(null, '/path/python') - } else if (/sys\.version_info/.test(args[args.length-1])) { + } else if (/sys\.version_info/.test(args[args.length - 1])) { cb(null, '3.0.0') } else { t.fail() @@ -107,7 +109,7 @@ test('find python - python too new', function (t) { } f.findPython() - function done(err) { + function done (err) { t.ok(/Could not find any Python/.test(err)) t.ok(/not supported/i.test(f.errorLog)) } @@ -117,10 +119,10 @@ test('find python - no python', function (t) { t.plan(2) var f = new TestPythonFinder(null, done) - f.execFile = function(program, args, opts, cb) { - if (/sys\.executable/.test(args[args.length-1])) { + f.execFile = function (program, args, opts, cb) { + if (/sys\.executable/.test(args[args.length - 1])) { cb(new Error('not found')) - } else if (/sys\.version_info/.test(args[args.length-1])) { + } else if (/sys\.version_info/.test(args[args.length - 1])) { cb(new Error('not a Python executable')) } else { t.fail() @@ -128,7 +130,7 @@ test('find python - no python', function (t) { } f.findPython() - function done(err) { + function done (err) { t.ok(/Could not find any Python/.test(err)) t.ok(/not in PATH/.test(f.errorLog)) } @@ -138,14 +140,14 @@ test('find python - no python2', function (t) { t.plan(2) var f = new TestPythonFinder(null, done) - f.execFile = function(program, args, opts, cb) { - if (/sys\.executable/.test(args[args.length-1])) { - if (program == 'python2') { + f.execFile = function (program, args, opts, cb) { + if (/sys\.executable/.test(args[args.length - 1])) { + if (program === 'python2') { cb(new Error('not found')) } else { cb(null, '/path/python') } - } else if (/sys\.version_info/.test(args[args.length-1])) { + } else if (/sys\.version_info/.test(args[args.length - 1])) { cb(null, '2.7.14') } else { t.fail() @@ -153,7 +155,7 @@ test('find python - no python2', function (t) { } f.findPython() - function done(err, python) { + function done (err, python) { t.strictEqual(err, null) t.strictEqual(python, '/path/python') } @@ -166,8 +168,8 @@ test('find python - no python2, no python, unix', function (t) { f.checkPyLauncher = t.fail f.win = false - f.execFile = function(program, args, opts, cb) { - if (/sys\.executable/.test(args[args.length-1])) { + f.execFile = function (program, args, opts, cb) { + if (/sys\.executable/.test(args[args.length - 1])) { cb(new Error('not found')) } else { t.fail() @@ -175,7 +177,7 @@ test('find python - no python2, no python, unix', function (t) { } f.findPython() - function done(err) { + function done (err) { t.ok(/Could not find any Python/.test(err)) t.ok(/not in PATH/.test(f.errorLog)) } @@ -187,15 +189,15 @@ test('find python - no python, use python launcher', function (t) { var f = new TestPythonFinder(null, done) f.win = true - f.execFile = function(program, args, opts, cb) { + f.execFile = function (program, args, opts, cb) { if (program === 'py.exe') { t.notEqual(args.indexOf('-2'), -1) t.notEqual(args.indexOf('-c'), -1) return cb(null, 'Z:\\snake.exe') } - if (/sys\.executable/.test(args[args.length-1])) { + if (/sys\.executable/.test(args[args.length - 1])) { cb(new Error('not found')) - } else if (/sys\.version_info/.test(args[args.length-1])) { + } else if (/sys\.version_info/.test(args[args.length - 1])) { if (program === 'Z:\\snake.exe') { cb(null, '2.7.14') } else { @@ -207,7 +209,7 @@ test('find python - no python, use python launcher', function (t) { } f.findPython() - function done(err, python) { + function done (err, python) { t.strictEqual(err, null) t.strictEqual(python, 'Z:\\snake.exe') } @@ -219,11 +221,11 @@ test('find python - python 3, use python launcher', function (t) { var f = new TestPythonFinder(null, done) f.win = true - f.execFile = function(program, args, opts, cb) { + f.execFile = function (program, args, opts, cb) { if (program === 'py.exe') { - f.execFile = function(program, args, opts, cb) { + f.execFile = function (program, args, opts, cb) { poison(f, 'execFile') - if (/sys\.version_info/.test(args[args.length-1])) { + if (/sys\.version_info/.test(args[args.length - 1])) { cb(null, '2.7.14') } else { t.fail() @@ -233,9 +235,9 @@ test('find python - python 3, use python launcher', function (t) { t.notEqual(args.indexOf('-c'), -1) return cb(null, 'Z:\\snake.exe') } - if (/sys\.executable/.test(args[args.length-1])) { + if (/sys\.executable/.test(args[args.length - 1])) { cb(null, '/path/python') - } else if (/sys\.version_info/.test(args[args.length-1])) { + } else if (/sys\.version_info/.test(args[args.length - 1])) { cb(null, '3.0.0') } else { t.fail() @@ -243,76 +245,76 @@ test('find python - python 3, use python launcher', function (t) { } f.findPython() - function done(err, python) { + function done (err, python) { t.strictEqual(err, null) t.strictEqual(python, 'Z:\\snake.exe') } }) test('find python - python 3, use python launcher, python 2 too old', - function (t) { - t.plan(6) - - var f = new TestPythonFinder(null, done) - f.win = true - - f.execFile = function(program, args, opts, cb) { - if (program === 'py.exe') { - f.execFile = function(program, args, opts, cb) { - if (/sys\.version_info/.test(args[args.length-1])) { - f.execFile = function(program, args, opts, cb) { - if (/sys\.version_info/.test(args[args.length-1])) { - poison(f, 'execFile') - t.strictEqual(program, f.defaultLocation) - cb(new Error('not found')) - } else { - t.fail() + function (t) { + t.plan(6) + + var f = new TestPythonFinder(null, done) + f.win = true + + f.execFile = function (program, args, opts, cb) { + if (program === 'py.exe') { + f.execFile = function (program, args, opts, cb) { + if (/sys\.version_info/.test(args[args.length - 1])) { + f.execFile = function (program, args, opts, cb) { + if (/sys\.version_info/.test(args[args.length - 1])) { + poison(f, 'execFile') + t.strictEqual(program, f.defaultLocation) + cb(new Error('not found')) + } else { + t.fail() + } } + t.strictEqual(program, 'Z:\\snake.exe') + cb(null, '2.3.4') + } else { + t.fail() } - t.strictEqual(program, 'Z:\\snake.exe') - cb(null, '2.3.4') - } else { - t.fail() } + t.notEqual(args.indexOf('-2'), -1) + t.notEqual(args.indexOf('-c'), -1) + return cb(null, 'Z:\\snake.exe') + } + if (/sys\.executable/.test(args[args.length - 1])) { + cb(null, '/path/python') + } else if (/sys\.version_info/.test(args[args.length - 1])) { + cb(null, '3.0.0') + } else { + t.fail() } - t.notEqual(args.indexOf('-2'), -1) - t.notEqual(args.indexOf('-c'), -1) - return cb(null, 'Z:\\snake.exe') - } - if (/sys\.executable/.test(args[args.length-1])) { - cb(null, '/path/python') - } else if (/sys\.version_info/.test(args[args.length-1])) { - cb(null, '3.0.0') - } else { - t.fail() } - } - f.findPython() + f.findPython() - function done(err) { - t.ok(/Could not find any Python/.test(err)) - t.ok(/not supported/i.test(f.errorLog)) - } -}) + function done (err) { + t.ok(/Could not find any Python/.test(err)) + t.ok(/not supported/i.test(f.errorLog)) + } + }) test('find python - no python, no python launcher, good guess', function (t) { t.plan(4) - var re = /C:[\\\/]Python27[\\\/]python[.]exe/ + var re = /C:[\\/]Python27[\\/]python[.]exe/ var f = new TestPythonFinder(null, done) f.win = true - f.execFile = function(program, args, opts, cb) { + f.execFile = function (program, args, opts, cb) { if (program === 'py.exe') { - f.execFile = function(program, args, opts, cb) { + f.execFile = function (program, args, opts, cb) { poison(f, 'execFile') t.ok(re.test(program)) - t.ok(/sys\.version_info/.test(args[args.length-1])) + t.ok(/sys\.version_info/.test(args[args.length - 1])) cb(null, '2.7.14') } return cb(new Error('not found')) } - if (/sys\.executable/.test(args[args.length-1])) { + if (/sys\.executable/.test(args[args.length - 1])) { cb(new Error('not found')) } else { t.fail() @@ -320,7 +322,7 @@ test('find python - no python, no python launcher, good guess', function (t) { } f.findPython() - function done(err, python) { + function done (err, python) { t.strictEqual(err, null) t.ok(re.test(python)) } @@ -332,10 +334,10 @@ test('find python - no python, no python launcher, bad guess', function (t) { var f = new TestPythonFinder(null, done) f.win = true - f.execFile = function(program, args, opts, cb) { - if (/sys\.executable/.test(args[args.length-1])) { + f.execFile = function (program, args, opts, cb) { + if (/sys\.executable/.test(args[args.length - 1])) { cb(new Error('not found')) - } else if (/sys\.version_info/.test(args[args.length-1])) { + } else if (/sys\.version_info/.test(args[args.length - 1])) { cb(new Error('not a Python executable')) } else { t.fail() @@ -343,7 +345,7 @@ test('find python - no python, no python launcher, bad guess', function (t) { } f.findPython() - function done(err) { + function done (err) { t.ok(/Could not find any Python/.test(err)) t.ok(/not in PATH/.test(f.errorLog)) } diff --git a/test/test-find-visualstudio.js b/test/test-find-visualstudio.js index cf6349c808..acbe7000da 100644 --- a/test/test-find-visualstudio.js +++ b/test/test-find-visualstudio.js @@ -1,6 +1,6 @@ 'use strict' -var test = require('tap').test +const test = require('tap').test const fs = require('fs') const path = require('path') const findVisualStudio = require('../lib/find-visualstudio') diff --git a/test/test-install.js b/test/test-install.js index 9e44c39bc1..c3317155e0 100644 --- a/test/test-install.js +++ b/test/test-install.js @@ -1,7 +1,7 @@ 'use strict' -var test = require('tap').test -var install = require('../lib/install').test.install +const test = require('tap').test +const install = require('../lib/install').test.install require('npmlog').level = 'error' // we expect a warning @@ -13,7 +13,7 @@ test('EACCES retry once', function (t) { var err = new Error() err.code = 'EACCES' cb(err) - t.ok(true); + t.ok(true) } var gyp = {} diff --git a/test/test-options.js b/test/test-options.js index 51d473308c..252baa2035 100644 --- a/test/test-options.js +++ b/test/test-options.js @@ -1,15 +1,15 @@ -'use strict'; +'use strict' -var test = require('tap').test -var gyp = require('../lib/node-gyp') +const test = require('tap').test +const gyp = require('../lib/node-gyp') test('options in environment', function (t) { t.plan(1) // `npm test` dumps a ton of npm_config_* variables in the environment. Object.keys(process.env) - .filter(function(key) { return /^npm_config_/.test(key) }) - .forEach(function(key) { delete process.env[key] }) + .filter(function (key) { return /^npm_config_/.test(key) }) + .forEach(function (key) { delete process.env[key] }) // Zero-length keys should get filtered out. process.env.npm_config_ = '42' @@ -18,8 +18,8 @@ test('options in environment', function (t) { // Except loglevel. process.env.npm_config_loglevel = 'debug' - var g = gyp(); - g.parseArgv(['rebuild']) // Also sets opts.argv. + var g = gyp() + g.parseArgv(['rebuild']) // Also sets opts.argv. t.deepEqual(Object.keys(g.opts).sort(), ['argv', 'x']) }) diff --git a/test/test-process-release.js b/test/test-process-release.js index 83998af041..e4370e59ee 100644 --- a/test/test-process-release.js +++ b/test/test-process-release.js @@ -1,5 +1,7 @@ -var test = require('tap').test -var processRelease = require('../lib/process-release') +'use strict' + +const test = require('tap').test +const processRelease = require('../lib/process-release') test('test process release - process.version = 0.8.20', function (t) { t.plan(2) @@ -17,7 +19,7 @@ test('test process release - process.version = 0.8.20', function (t) { shasumsUrl: 'https://nodejs.org/dist/v0.8.20/SHASUMS256.txt', versionDir: '0.8.20', ia32: { libUrl: 'https://nodejs.org/dist/v0.8.20/node.lib', libPath: 'node.lib' }, - x64: { libUrl: 'https://nodejs.org/dist/v0.8.20/x64/node.lib', libPath: 'x64/node.lib' }, + x64: { libUrl: 'https://nodejs.org/dist/v0.8.20/x64/node.lib', libPath: 'x64/node.lib' } }) }) @@ -37,7 +39,7 @@ test('test process release - process.version = 0.10.21', function (t) { shasumsUrl: 'https://nodejs.org/dist/v0.10.21/SHASUMS256.txt', versionDir: '0.10.21', ia32: { libUrl: 'https://nodejs.org/dist/v0.10.21/node.lib', libPath: 'node.lib' }, - x64: { libUrl: 'https://nodejs.org/dist/v0.10.21/x64/node.lib', libPath: 'x64/node.lib' }, + x64: { libUrl: 'https://nodejs.org/dist/v0.10.21/x64/node.lib', libPath: 'x64/node.lib' } }) }) @@ -58,7 +60,7 @@ test('test process release - process.version = 0.12.9', function (t) { shasumsUrl: 'https://nodejs.org/dist/v0.12.9/SHASUMS256.txt', versionDir: '0.12.9', ia32: { libUrl: 'https://nodejs.org/dist/v0.12.9/node.lib', libPath: 'node.lib' }, - x64: { libUrl: 'https://nodejs.org/dist/v0.12.9/x64/node.lib', libPath: 'x64/node.lib' }, + x64: { libUrl: 'https://nodejs.org/dist/v0.12.9/x64/node.lib', libPath: 'x64/node.lib' } }) }) @@ -79,7 +81,7 @@ test('test process release - process.version = 0.10.41', function (t) { shasumsUrl: 'https://nodejs.org/dist/v0.10.41/SHASUMS256.txt', versionDir: '0.10.41', ia32: { libUrl: 'https://nodejs.org/dist/v0.10.41/node.lib', libPath: 'node.lib' }, - x64: { libUrl: 'https://nodejs.org/dist/v0.10.41/x64/node.lib', libPath: 'x64/node.lib' }, + x64: { libUrl: 'https://nodejs.org/dist/v0.10.41/x64/node.lib', libPath: 'x64/node.lib' } }) }) @@ -100,7 +102,7 @@ test('test process release - process.release ~ node@0.10.42', function (t) { shasumsUrl: 'https://nodejs.org/dist/v0.10.42/SHASUMS256.txt', versionDir: '0.10.42', ia32: { libUrl: 'https://nodejs.org/dist/v0.10.42/node.lib', libPath: 'node.lib' }, - x64: { libUrl: 'https://nodejs.org/dist/v0.10.42/x64/node.lib', libPath: 'x64/node.lib' }, + x64: { libUrl: 'https://nodejs.org/dist/v0.10.42/x64/node.lib', libPath: 'x64/node.lib' } }) }) @@ -121,7 +123,7 @@ test('test process release - process.release ~ node@0.12.10', function (t) { shasumsUrl: 'https://nodejs.org/dist/v0.12.10/SHASUMS256.txt', versionDir: '0.12.10', ia32: { libUrl: 'https://nodejs.org/dist/v0.12.10/node.lib', libPath: 'node.lib' }, - x64: { libUrl: 'https://nodejs.org/dist/v0.12.10/x64/node.lib', libPath: 'x64/node.lib' }, + x64: { libUrl: 'https://nodejs.org/dist/v0.12.10/x64/node.lib', libPath: 'x64/node.lib' } }) }) @@ -144,7 +146,7 @@ test('test process release - process.release ~ node@4.1.23', function (t) { shasumsUrl: 'https://nodejs.org/dist/v4.1.23/SHASUMS256.txt', versionDir: '4.1.23', ia32: { libUrl: 'https://nodejs.org/dist/v4.1.23/win-x86/node.lib', libPath: 'win-x86/node.lib' }, - x64: { libUrl: 'https://nodejs.org/dist/v4.1.23/win-x64/node.lib', libPath: 'win-x64/node.lib' }, + x64: { libUrl: 'https://nodejs.org/dist/v4.1.23/win-x64/node.lib', libPath: 'win-x64/node.lib' } }) }) @@ -167,7 +169,7 @@ test('test process release - process.release ~ node@4.1.23 / corp build', functi shasumsUrl: 'https://some.custom.location/SHASUMS256.txt', versionDir: '4.1.23', ia32: { libUrl: 'https://some.custom.location/win-x86/node.lib', libPath: 'win-x86/node.lib' }, - x64: { libUrl: 'https://some.custom.location/win-x64/node.lib', libPath: 'win-x64/node.lib' }, + x64: { libUrl: 'https://some.custom.location/win-x64/node.lib', libPath: 'win-x64/node.lib' } }) }) @@ -190,7 +192,7 @@ test('test process release - process.release ~ node@4.1.23 --target=0.10.40', fu shasumsUrl: 'https://nodejs.org/dist/v0.10.40/SHASUMS256.txt', versionDir: '0.10.40', ia32: { libUrl: 'https://nodejs.org/dist/v0.10.40/node.lib', libPath: 'node.lib' }, - x64: { libUrl: 'https://nodejs.org/dist/v0.10.40/x64/node.lib', libPath: 'x64/node.lib' }, + x64: { libUrl: 'https://nodejs.org/dist/v0.10.40/x64/node.lib', libPath: 'x64/node.lib' } }) }) @@ -213,7 +215,7 @@ test('test process release - process.release ~ node@4.1.23 --dist-url=https://fo shasumsUrl: 'https://foo.bar/baz/v4.1.23/SHASUMS256.txt', versionDir: '4.1.23', ia32: { libUrl: 'https://foo.bar/baz/v4.1.23/win-x86/node.lib', libPath: 'win-x86/node.lib' }, - x64: { libUrl: 'https://foo.bar/baz/v4.1.23/win-x64/node.lib', libPath: 'win-x64/node.lib' }, + x64: { libUrl: 'https://foo.bar/baz/v4.1.23/win-x64/node.lib', libPath: 'win-x64/node.lib' } }) }) @@ -236,11 +238,10 @@ test('test process release - process.release ~ frankenstein@4.1.23', function (t shasumsUrl: 'https://frankensteinjs.org/dist/v4.1.23/SHASUMS256.txt', versionDir: 'frankenstein-4.1.23', ia32: { libUrl: 'https://frankensteinjs.org/dist/v4.1.23/win-x86/frankenstein.lib', libPath: 'win-x86/frankenstein.lib' }, - x64: { libUrl: 'https://frankensteinjs.org/dist/v4.1.23/win-x64/frankenstein.lib', libPath: 'win-x64/frankenstein.lib' }, + x64: { libUrl: 'https://frankensteinjs.org/dist/v4.1.23/win-x64/frankenstein.lib', libPath: 'win-x64/frankenstein.lib' } }) }) - test('test process release - process.release ~ frankenstein@4.1.23 --dist-url=http://foo.bar/baz/', function (t) { t.plan(2) @@ -260,7 +261,7 @@ test('test process release - process.release ~ frankenstein@4.1.23 --dist-url=ht shasumsUrl: 'http://foo.bar/baz/v4.1.23/SHASUMS256.txt', versionDir: 'frankenstein-4.1.23', ia32: { libUrl: 'http://foo.bar/baz/v4.1.23/win-x86/frankenstein.lib', libPath: 'win-x86/frankenstein.lib' }, - x64: { libUrl: 'http://foo.bar/baz/v4.1.23/win-x64/frankenstein.lib', libPath: 'win-x64/frankenstein.lib' }, + x64: { libUrl: 'http://foo.bar/baz/v4.1.23/win-x64/frankenstein.lib', libPath: 'win-x64/frankenstein.lib' } }) }) @@ -283,11 +284,10 @@ test('test process release - process.release ~ node@4.0.0-rc.4', function (t) { shasumsUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/SHASUMS256.txt', versionDir: '4.0.0-rc.4', ia32: { libUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-x86/node.lib', libPath: 'win-x86/node.lib' }, - x64: { libUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-x64/node.lib', libPath: 'win-x64/node.lib' }, + x64: { libUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-x64/node.lib', libPath: 'win-x64/node.lib' } }) }) - test('test process release - process.release ~ node@4.0.0-rc.4 passed as argv[0]', function (t) { t.plan(2) @@ -309,11 +309,10 @@ test('test process release - process.release ~ node@4.0.0-rc.4 passed as argv[0] shasumsUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/SHASUMS256.txt', versionDir: '4.0.0-rc.4', ia32: { libUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-x86/node.lib', libPath: 'win-x86/node.lib' }, - x64: { libUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-x64/node.lib', libPath: 'win-x64/node.lib' }, + x64: { libUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-x64/node.lib', libPath: 'win-x64/node.lib' } }) }) - test('test process release - process.release ~ node@4.0.0-rc.4 - bogus string passed as argv[0]', function (t) { t.plan(2) @@ -335,7 +334,7 @@ test('test process release - process.release ~ node@4.0.0-rc.4 - bogus string pa shasumsUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/SHASUMS256.txt', versionDir: '4.0.0-rc.4', ia32: { libUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-x86/node.lib', libPath: 'win-x86/node.lib' }, - x64: { libUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-x64/node.lib', libPath: 'win-x64/node.lib' }, + x64: { libUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/win-x64/node.lib', libPath: 'win-x64/node.lib' } }) }) @@ -360,7 +359,7 @@ test('test process release - NODEJS_ORG_MIRROR', function (t) { shasumsUrl: 'http://foo.bar/v4.1.23/SHASUMS256.txt', versionDir: '4.1.23', ia32: { libUrl: 'http://foo.bar/v4.1.23/win-x86/node.lib', libPath: 'win-x86/node.lib' }, - x64: { libUrl: 'http://foo.bar/v4.1.23/win-x64/node.lib', libPath: 'win-x64/node.lib' }, + x64: { libUrl: 'http://foo.bar/v4.1.23/win-x64/node.lib', libPath: 'win-x64/node.lib' } }) delete process.env.NODEJS_ORG_MIRROR