diff --git a/bin/node-gyp.js b/bin/node-gyp.js index 13f2d399f7..49b5721d02 100755 --- a/bin/node-gyp.js +++ b/bin/node-gyp.js @@ -131,7 +131,7 @@ function errorMessage () { function issueMessage () { errorMessage() - log.error('', [ 'This is a bug in `node-gyp`.', + 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')) diff --git a/lib/configure.js b/lib/configure.js index 20b955cabc..564564eea4 100644 --- a/lib/configure.js +++ b/lib/configure.js @@ -17,7 +17,7 @@ if (win) { function configure (gyp, argv, callback) { var python var buildDir = path.resolve('build') - var configNames = [ 'config.gypi', 'common.gypi' ] + var configNames = ['config.gypi', 'common.gypi'] var configs = [] var nodeDir var release = processRelease(argv, gyp, process.version, process.release) @@ -60,7 +60,7 @@ function configure (gyp, argv, callback) { // into devdir. Otherwise only install if they're not already there. gyp.opts.ensure = !gyp.opts.tarball - gyp.commands.install([ release.version ], function (err) { + gyp.commands.install([release.version], function (err) { if (err) { return callback(err) } @@ -132,7 +132,7 @@ function configure (gyp, argv, callback) { // set the target_arch variable variables.target_arch = gyp.opts.arch || process.arch || 'ia32' if (variables.target_arch === 'arm64') { - defaults['msvs_configuration_platform'] = 'ARM64' + defaults.msvs_configuration_platform = 'ARM64' } // set the node development directory @@ -142,22 +142,22 @@ function configure (gyp, argv, callback) { variables.standalone_static_library = gyp.opts.thin ? 0 : 1 if (win) { - process.env['GYP_MSVS_VERSION'] = Math.min(vsInfo.versionYear, 2015) - process.env['GYP_MSVS_OVERRIDE_PATH'] = vsInfo.path - defaults['msbuild_toolset'] = vsInfo.toolset + process.env.GYP_MSVS_VERSION = Math.min(vsInfo.versionYear, 2015) + process.env.GYP_MSVS_OVERRIDE_PATH = vsInfo.path + defaults.msbuild_toolset = vsInfo.toolset if (vsInfo.sdk) { - defaults['msvs_windows_target_platform_version'] = vsInfo.sdk + defaults.msvs_windows_target_platform_version = vsInfo.sdk } if (variables.target_arch === 'arm64') { if (vsInfo.versionMajor > 15 || (vsInfo.versionMajor === 15 && vsInfo.versionMajor >= 9)) { - defaults['msvs_enable_marmasm'] = 1 + defaults.msvs_enable_marmasm = 1 } else { log.warn('Compiling ARM64 assembly is only available in\n' + 'Visual Studio 2017 version 15.9 and above') } } - variables['msbuild_path'] = vsInfo.msBuild + variables.msbuild_path = vsInfo.msBuild } // loop through the rest of the opts and add the unknown ones as variables. @@ -190,7 +190,7 @@ function configure (gyp, argv, callback) { 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) { @@ -335,7 +335,7 @@ function configure (gyp, argv, callback) { 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) } diff --git a/lib/find-python.js b/lib/find-python.js index bd7cb850ee..c12ccc3bb2 100644 --- a/lib/find-python.js +++ b/lib/find-python.js @@ -16,8 +16,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.7.x || >=3.5.0', // These can be overridden for testing: @@ -45,7 +45,7 @@ PythonFinder.prototype = { function getChecks () { if (this.env.NODE_GYP_FORCE_PYTHON) { - return [ { + return [{ before: () => { this.addLog( 'checking Python explicitly set from NODE_GYP_FORCE_PYTHON') @@ -54,7 +54,7 @@ PythonFinder.prototype = { }, check: this.checkCommand, arg: this.env.NODE_GYP_FORCE_PYTHON - } ] + }] } var checks = [ @@ -144,7 +144,7 @@ PythonFinder.prototype = { return this.fail() } - const args = [ runChecks.bind(this) ] + const args = [runChecks.bind(this)] if (check.arg) { args.unshift(check.arg) } @@ -196,7 +196,7 @@ 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, + this.run(this.pyLauncher, ['-2', ...this.argsExecutable], false, function (err, execPath) { // Possible outcomes: same as checkCommand if (err) { diff --git a/lib/install.js b/lib/install.js index 3730c0965f..11537e6025 100644 --- a/lib/install.js +++ b/lib/install.js @@ -24,7 +24,7 @@ function install (fs, gyp, argv, callback) { if (err) { log.warn('install', 'got an error, rolling back install') // roll-back the install if anything went wrong - gyp.commands.remove([ release.versionDir ], function () { + gyp.commands.remove([release.versionDir], function () { callback(err) }) } else { @@ -298,7 +298,7 @@ function install (fs, gyp, argv, callback) { function downloadNodeLib (done) { log.verbose('on Windows; need to download `' + release.name + '.lib`...') - var archs = [ 'ia32', 'x64' ] + var archs = ['ia32', 'x64'] var async = archs.length archs.forEach(function (arch) { var dir = path.resolve(devDir, arch) @@ -392,7 +392,7 @@ function download (gyp, env, url) { uri: url, headers: { 'User-Agent': 'node-gyp v' + gyp.version + ' (node ' + process.version + ')', - 'Connection': 'keep-alive' + Connection: 'keep-alive' } } diff --git a/lib/node-gyp.js b/lib/node-gyp.js index 91880f9433..9d24103900 100644 --- a/lib/node-gyp.js +++ b/lib/node-gyp.js @@ -18,8 +18,8 @@ const commands = [ 'remove' ] const aliases = { - 'ls': 'list', - 'rm': 'remove' + ls: 'list', + rm: 'remove' } // differentiate node-gyp's logs from npm's @@ -72,7 +72,7 @@ proto.configDefs = { loglevel: String, // everywhere python: String, // 'configure' 'dist-url': String, // 'install' - 'tarball': String, // 'install' + tarball: String, // 'install' jobs: String, // 'build' thin: String // 'configure' } @@ -167,7 +167,7 @@ proto.spawn = function spawn (command, args, opts) { opts = {} } if (!opts.silent && !opts.stdio) { - opts.stdio = [ 0, 1, 2 ] + opts.stdio = [0, 1, 2] } var cp = childProcess.spawn(command, args, opts) log.info('spawn', command) diff --git a/lib/process-release.js b/lib/process-release.js index 0acab061bd..4f2f59f205 100644 --- a/lib/process-release.js +++ b/lib/process-release.js @@ -1,3 +1,5 @@ +/* eslint-disable node/no-deprecated-api */ + 'use strict' const semver = require('semver') diff --git a/package.json b/package.json index fe68798faf..2e11a2e551 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "bindings": "~1.2.1", "nan": "^2.0.0", "require-inject": "~1.3.0", - "standard": "~12.0.1", + "standard": "~14.3.1", "tap": "~12.7.0" }, "scripts": { diff --git a/test/process-exec-sync.js b/test/process-exec-sync.js index f786484027..21763bc26d 100644 --- a/test/process-exec-sync.js +++ b/test/process-exec-sync.js @@ -67,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) }) diff --git a/test/test-addon.js b/test/test-addon.js index f97215c0a2..f79eff73c1 100644 --- a/test/test-addon.js +++ b/test/test-addon.js @@ -15,18 +15,18 @@ function runHello (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 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 () { var data try { - data = execFileSync('python', [ 'fixtures/test-charmap.py' ], + data = execFileSync('python', ['fixtures/test-charmap.py'], { cwd: __dirname }) } catch (err) { return false @@ -39,7 +39,7 @@ 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] @@ -59,9 +59,9 @@ test('build simple addon in path with non-ascii characters', function (t) { } var testDirNames = { - 'cp936': '文件夹', - 'cp1252': 'Latīna', - 'cp932': 'フォルダ' + cp936: '文件夹', + cp1252: 'Latīna', + cp932: 'フォルダ' } // Select non-ascii characters by current encoding var testDirName = testDirNames[getEncoding()] @@ -136,7 +136,7 @@ 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] diff --git a/test/test-configure-python.js b/test/test-configure-python.js index 41b8c70427..518bf036d0 100644 --- a/test/test-configure-python.js +++ b/test/test-configure-python.js @@ -6,10 +6,10 @@ const gyp = require('../lib/node-gyp') const requireInject = require('require-inject') const configure = requireInject('../lib/configure', { 'graceful-fs': { - 'openSync': function () { return 0 }, - 'closeSync': function () { }, - 'writeFile': function (file, data, cb) { cb() }, - 'stat': function (file, cb) { cb(null, {}) } + openSync: function () { return 0 }, + closeSync: function () { }, + writeFile: function (file, data, cb) { cb() }, + stat: function (file, cb) { cb(null, {}) } } }) @@ -42,10 +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 } @@ -57,16 +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-find-accessible-sync.js b/test/test-find-accessible-sync.js index 32234f5389..0a2e584c4f 100644 --- a/test/test-find-accessible-sync.js +++ b/test/test-find-accessible-sync.js @@ -5,8 +5,8 @@ const path = require('path') const requireInject = require('require-inject') const configure = requireInject('../lib/configure', { 'graceful-fs': { - 'closeSync': function () { return undefined }, - 'openSync': function (path) { + closeSync: function () { return undefined }, + openSync: function (path) { if (readableFiles.some(function (f) { return f === path })) { return 0 } else { @@ -38,7 +38,7 @@ test('find accessible - empty array', function (t) { test('find accessible - single item array, readable', function (t) { t.plan(1) - var candidates = [ readableFile ] + var candidates = [readableFile] var found = configure.test.findAccessibleSync('test', dir, candidates) t.strictEqual(found, path.resolve(dir, readableFile)) }) @@ -46,7 +46,7 @@ test('find accessible - single item array, readable', function (t) { test('find accessible - single item array, readable in subdir', function (t) { t.plan(1) - var candidates = [ readableFileInDir ] + var candidates = [readableFileInDir] var found = configure.test.findAccessibleSync('test', dir, candidates) t.strictEqual(found, path.resolve(dir, readableFileInDir)) }) @@ -54,7 +54,7 @@ test('find accessible - single item array, readable in subdir', function (t) { test('find accessible - single item array, unreadable', function (t) { t.plan(1) - var candidates = [ 'unreadable_file' ] + var candidates = ['unreadable_file'] var found = configure.test.findAccessibleSync('test', dir, candidates) t.strictEqual(found, undefined) }) @@ -62,7 +62,7 @@ test('find accessible - single item array, unreadable', function (t) { test('find accessible - multi item array, no matches', function (t) { t.plan(1) - var candidates = [ 'non_existent_file', 'unreadable_file' ] + var candidates = ['non_existent_file', 'unreadable_file'] var found = configure.test.findAccessibleSync('test', dir, candidates) t.strictEqual(found, undefined) }) @@ -70,7 +70,7 @@ test('find accessible - multi item array, no matches', function (t) { test('find accessible - multi item array, single match', function (t) { t.plan(1) - var candidates = [ 'non_existent_file', readableFile ] + var candidates = ['non_existent_file', readableFile] var found = configure.test.findAccessibleSync('test', dir, candidates) t.strictEqual(found, path.resolve(dir, readableFile)) }) @@ -78,7 +78,7 @@ test('find accessible - multi item array, single match', function (t) { test('find accessible - multi item array, return first match', function (t) { t.plan(1) - var candidates = [ 'non_existent_file', anotherReadableFile, readableFile ] + var candidates = ['non_existent_file', anotherReadableFile, readableFile] var found = configure.test.findAccessibleSync('test', dir, candidates) t.strictEqual(found, path.resolve(dir, anotherReadableFile)) }) diff --git a/test/test-find-node-directory.js b/test/test-find-node-directory.js index 767b6f6b37..f1380d162a 100644 --- a/test/test-find-node-directory.js +++ b/test/test-find-node-directory.js @@ -4,7 +4,7 @@ const test = require('tap').test const path = require('path') const findNodeDirectory = require('../lib/find-node-directory') -const platforms = [ 'darwin', 'freebsd', 'linux', 'sunos', 'win32', 'aix' ] +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 @@ -62,8 +62,10 @@ test('test find-node-directory - node in build release dir', function (t) { if (platforms[next] === 'win32') { 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( diff --git a/test/test-process-release.js b/test/test-process-release.js index e4370e59ee..a6a87bae0e 100644 --- a/test/test-process-release.js +++ b/test/test-process-release.js @@ -293,7 +293,7 @@ test('test process release - process.release ~ node@4.0.0-rc.4 passed as argv[0] // note the missing 'v' on the arg, it should normalise when checking // whether we're on the default or not - var release = processRelease([ '4.0.0-rc.4' ], { opts: {} }, 'v4.0.0-rc.4', { + var release = processRelease(['4.0.0-rc.4'], { opts: {} }, 'v4.0.0-rc.4', { name: 'node', headersUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/node-v4.0.0-rc.4-headers.tar.gz' }) @@ -318,7 +318,7 @@ test('test process release - process.release ~ node@4.0.0-rc.4 - bogus string pa // additional arguments can be passed in on the commandline that should be ignored if they // are not specifying a valid version @ position 0 - var release = processRelease([ 'this is no version!' ], { opts: {} }, 'v4.0.0-rc.4', { + var release = processRelease(['this is no version!'], { opts: {} }, 'v4.0.0-rc.4', { name: 'node', headersUrl: 'https://nodejs.org/download/rc/v4.0.0-rc.4/node-v4.0.0-rc.4-headers.tar.gz' })