Skip to content

Commit 1196e99

Browse files
committed
src: update to standard@14
PR-URL: #1899 Reviewed-By: João Reis <[email protected]> Reviewed-By: Richard Lau <[email protected]>
1 parent 53ee7df commit 1196e99

13 files changed

+61
-57
lines changed

bin/node-gyp.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ function errorMessage () {
131131

132132
function issueMessage () {
133133
errorMessage()
134-
log.error('', [ 'This is a bug in `node-gyp`.',
134+
log.error('', ['This is a bug in `node-gyp`.',
135135
'Try to update node-gyp and file an Issue if it does not help:',
136136
' <https://github.com/nodejs/node-gyp/issues>'
137137
].join('\n'))

lib/configure.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ if (win) {
1717
function configure (gyp, argv, callback) {
1818
var python
1919
var buildDir = path.resolve('build')
20-
var configNames = [ 'config.gypi', 'common.gypi' ]
20+
var configNames = ['config.gypi', 'common.gypi']
2121
var configs = []
2222
var nodeDir
2323
var release = processRelease(argv, gyp, process.version, process.release)
@@ -60,7 +60,7 @@ function configure (gyp, argv, callback) {
6060
// into devdir. Otherwise only install if they're not already there.
6161
gyp.opts.ensure = !gyp.opts.tarball
6262

63-
gyp.commands.install([ release.version ], function (err) {
63+
gyp.commands.install([release.version], function (err) {
6464
if (err) {
6565
return callback(err)
6666
}
@@ -132,7 +132,7 @@ function configure (gyp, argv, callback) {
132132
// set the target_arch variable
133133
variables.target_arch = gyp.opts.arch || process.arch || 'ia32'
134134
if (variables.target_arch === 'arm64') {
135-
defaults['msvs_configuration_platform'] = 'ARM64'
135+
defaults.msvs_configuration_platform = 'ARM64'
136136
}
137137

138138
// set the node development directory
@@ -142,22 +142,22 @@ function configure (gyp, argv, callback) {
142142
variables.standalone_static_library = gyp.opts.thin ? 0 : 1
143143

144144
if (win) {
145-
process.env['GYP_MSVS_VERSION'] = Math.min(vsInfo.versionYear, 2015)
146-
process.env['GYP_MSVS_OVERRIDE_PATH'] = vsInfo.path
147-
defaults['msbuild_toolset'] = vsInfo.toolset
145+
process.env.GYP_MSVS_VERSION = Math.min(vsInfo.versionYear, 2015)
146+
process.env.GYP_MSVS_OVERRIDE_PATH = vsInfo.path
147+
defaults.msbuild_toolset = vsInfo.toolset
148148
if (vsInfo.sdk) {
149-
defaults['msvs_windows_target_platform_version'] = vsInfo.sdk
149+
defaults.msvs_windows_target_platform_version = vsInfo.sdk
150150
}
151151
if (variables.target_arch === 'arm64') {
152152
if (vsInfo.versionMajor > 15 ||
153153
(vsInfo.versionMajor === 15 && vsInfo.versionMajor >= 9)) {
154-
defaults['msvs_enable_marmasm'] = 1
154+
defaults.msvs_enable_marmasm = 1
155155
} else {
156156
log.warn('Compiling ARM64 assembly is only available in\n' +
157157
'Visual Studio 2017 version 15.9 and above')
158158
}
159159
}
160-
variables['msbuild_path'] = vsInfo.msBuild
160+
variables.msbuild_path = vsInfo.msBuild
161161
}
162162

163163
// loop through the rest of the opts and add the unknown ones as variables.
@@ -190,7 +190,7 @@ function configure (gyp, argv, callback) {
190190
var json = JSON.stringify(config, boolsToString, 2)
191191
log.verbose('build/' + configFilename, 'writing out config file: %s', configPath)
192192
configs.push(configPath)
193-
fs.writeFile(configPath, [ prefix, json, '' ].join('\n'), findConfigs)
193+
fs.writeFile(configPath, [prefix, json, ''].join('\n'), findConfigs)
194194
}
195195

196196
function findConfigs (err) {
@@ -335,7 +335,7 @@ function configure (gyp, argv, callback) {
335335
argv.unshift(gypScript)
336336

337337
// make sure python uses files that came with this particular node package
338-
var pypath = [ path.join(__dirname, '..', 'gyp', 'pylib') ]
338+
var pypath = [path.join(__dirname, '..', 'gyp', 'pylib')]
339339
if (process.env.PYTHONPATH) {
340340
pypath.push(process.env.PYTHONPATH)
341341
}

lib/find-python.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ function PythonFinder (configPython, callback) {
1616

1717
PythonFinder.prototype = {
1818
log: logWithPrefix(log, 'find Python'),
19-
argsExecutable: [ '-c', 'import sys; print(sys.executable);' ],
20-
argsVersion: [ '-c', 'import sys; print("%s.%s.%s" % sys.version_info[:3]);' ],
19+
argsExecutable: ['-c', 'import sys; print(sys.executable);'],
20+
argsVersion: ['-c', 'import sys; print("%s.%s.%s" % sys.version_info[:3]);'],
2121
semverRange: process.env.EXPERIMENTAL_NODE_GYP_PYTHON3 ? '2.7.x || >=3.5.0'
2222
: '>=2.6.0 <3.0.0',
2323

@@ -46,7 +46,7 @@ PythonFinder.prototype = {
4646

4747
function getChecks () {
4848
if (this.env.NODE_GYP_FORCE_PYTHON) {
49-
return [ {
49+
return [{
5050
before: () => {
5151
this.addLog(
5252
'checking Python explicitly set from NODE_GYP_FORCE_PYTHON')
@@ -55,7 +55,7 @@ PythonFinder.prototype = {
5555
},
5656
check: this.checkCommand,
5757
arg: this.env.NODE_GYP_FORCE_PYTHON
58-
} ]
58+
}]
5959
}
6060

6161
var checks = [
@@ -140,7 +140,7 @@ PythonFinder.prototype = {
140140
return this.fail()
141141
}
142142

143-
const args = [ runChecks.bind(this) ]
143+
const args = [runChecks.bind(this)]
144144
if (check.arg) {
145145
args.unshift(check.arg)
146146
}
@@ -192,7 +192,7 @@ PythonFinder.prototype = {
192192
checkPyLauncher: function checkPyLauncher (errorCallback) {
193193
this.log.verbose(
194194
`- executing "${this.pyLauncher}" to get Python 2 executable path`)
195-
this.run(this.pyLauncher, [ '-2', ...this.argsExecutable ], false,
195+
this.run(this.pyLauncher, ['-2', ...this.argsExecutable], false,
196196
function (err, execPath) {
197197
// Possible outcomes: same as checkCommand
198198
if (err) {

lib/install.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function install (fs, gyp, argv, callback) {
2424
if (err) {
2525
log.warn('install', 'got an error, rolling back install')
2626
// roll-back the install if anything went wrong
27-
gyp.commands.remove([ release.versionDir ], function () {
27+
gyp.commands.remove([release.versionDir], function () {
2828
callback(err)
2929
})
3030
} else {
@@ -298,7 +298,7 @@ function install (fs, gyp, argv, callback) {
298298

299299
function downloadNodeLib (done) {
300300
log.verbose('on Windows; need to download `' + release.name + '.lib`...')
301-
var archs = [ 'ia32', 'x64', 'arm64' ]
301+
var archs = ['ia32', 'x64', 'arm64']
302302
var async = archs.length
303303
archs.forEach(function (arch) {
304304
var dir = path.resolve(devDir, arch)
@@ -400,7 +400,7 @@ function download (gyp, env, url) {
400400
uri: url,
401401
headers: {
402402
'User-Agent': 'node-gyp v' + gyp.version + ' (node ' + process.version + ')',
403-
'Connection': 'keep-alive'
403+
Connection: 'keep-alive'
404404
}
405405
}
406406

lib/node-gyp.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ const commands = [
1818
'remove'
1919
]
2020
const aliases = {
21-
'ls': 'list',
22-
'rm': 'remove'
21+
ls: 'list',
22+
rm: 'remove'
2323
}
2424

2525
// differentiate node-gyp's logs from npm's
@@ -72,7 +72,7 @@ proto.configDefs = {
7272
loglevel: String, // everywhere
7373
python: String, // 'configure'
7474
'dist-url': String, // 'install'
75-
'tarball': String, // 'install'
75+
tarball: String, // 'install'
7676
jobs: String, // 'build'
7777
thin: String // 'configure'
7878
}
@@ -167,7 +167,7 @@ proto.spawn = function spawn (command, args, opts) {
167167
opts = {}
168168
}
169169
if (!opts.silent && !opts.stdio) {
170-
opts.stdio = [ 0, 1, 2 ]
170+
opts.stdio = [0, 1, 2]
171171
}
172172
var cp = childProcess.spawn(command, args, opts)
173173
log.info('spawn', command)

lib/process-release.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* eslint-disable node/no-deprecated-api */
2+
13
'use strict'
24

35
const semver = require('semver')

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"bindings": "~1.2.1",
4242
"nan": "^2.0.0",
4343
"require-inject": "~1.3.0",
44-
"standard": "~12.0.1",
44+
"standard": "~14.3.1",
4545
"tap": "~12.7.0"
4646
},
4747
"scripts": {

test/process-exec-sync.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ function processExecSync (file, args, options) {
6767
}
6868
}
6969

70-
[ 'stdout', 'stderr', 'status' ].forEach(function (file) {
70+
['stdout', 'stderr', 'status'].forEach(function (file) {
7171
child[file] = fs.readFileSync(tmpdir + '/' + file, options.encoding)
7272
setTimeout(unlinkFile, 500, tmpdir + '/' + file)
7373
})

test/test-addon.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ function runHello (hostProcess) {
1515
hostProcess = process.execPath
1616
}
1717
var testCode = "console.log(require('hello_world').hello())"
18-
return execFileSync(hostProcess, [ '-e', testCode ], { cwd: __dirname }).toString()
18+
return execFileSync(hostProcess, ['-e', testCode], { cwd: __dirname }).toString()
1919
}
2020

2121
function getEncoding () {
2222
var code = 'import locale;print(locale.getdefaultlocale()[1])'
23-
return execFileSync('python', [ '-c', code ]).toString().trim()
23+
return execFileSync('python', ['-c', code]).toString().trim()
2424
}
2525

2626
function checkCharmapValid () {
2727
var data
2828
try {
29-
data = execFileSync('python', [ 'fixtures/test-charmap.py' ],
29+
data = execFileSync('python', ['fixtures/test-charmap.py'],
3030
{ cwd: __dirname })
3131
} catch (err) {
3232
return false
@@ -39,7 +39,7 @@ test('build simple addon', function (t) {
3939
t.plan(3)
4040

4141
// Set the loglevel otherwise the output disappears when run via 'npm test'
42-
var cmd = [ nodeGyp, 'rebuild', '-C', addonPath, '--loglevel=verbose' ]
42+
var cmd = [nodeGyp, 'rebuild', '-C', addonPath, '--loglevel=verbose']
4343
var proc = execFile(process.execPath, cmd, function (err, stdout, stderr) {
4444
var logLines = stderr.toString().trim().split(/\r?\n/)
4545
var lastLine = logLines[logLines.length - 1]
@@ -59,9 +59,9 @@ test('build simple addon in path with non-ascii characters', function (t) {
5959
}
6060

6161
var testDirNames = {
62-
'cp936': '文件夹',
63-
'cp1252': 'Latīna',
64-
'cp932': 'フォルダ'
62+
cp936: '文件夹',
63+
cp1252: 'Latīna',
64+
cp932: 'フォルダ'
6565
}
6666
// Select non-ascii characters by current encoding
6767
var testDirName = testDirNames[getEncoding()]
@@ -136,7 +136,7 @@ test('addon works with renamed host executable', function (t) {
136136
var notNodePath = path.join(os.tmpdir(), 'notnode' + path.extname(process.execPath))
137137
fs.copyFileSync(process.execPath, notNodePath)
138138

139-
var cmd = [ nodeGyp, 'rebuild', '-C', addonPath, '--loglevel=verbose' ]
139+
var cmd = [nodeGyp, 'rebuild', '-C', addonPath, '--loglevel=verbose']
140140
var proc = execFile(process.execPath, cmd, function (err, stdout, stderr) {
141141
var logLines = stderr.toString().trim().split(/\r?\n/)
142142
var lastLine = logLines[logLines.length - 1]

test/test-configure-python.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ const gyp = require('../lib/node-gyp')
66
const requireInject = require('require-inject')
77
const configure = requireInject('../lib/configure', {
88
'graceful-fs': {
9-
'openSync': function () { return 0 },
10-
'closeSync': function () { },
11-
'writeFile': function (file, data, cb) { cb() },
12-
'stat': function (file, cb) { cb(null, {}) }
9+
openSync: function () { return 0 },
10+
closeSync: function () { },
11+
writeFile: function (file, data, cb) { cb() },
12+
stat: function (file, cb) { cb(null, {}) }
1313
}
1414
})
1515

@@ -42,10 +42,10 @@ test('configure PYTHONPATH with existing env of one dir', function (t) {
4242
var prog = gyp()
4343
prog.parseArgv([])
4444
prog.spawn = function () {
45-
t.equal(process.env.PYTHONPATH, [ EXPECTED_PYPATH, existingPath ].join(SEPARATOR))
45+
t.equal(process.env.PYTHONPATH, [EXPECTED_PYPATH, existingPath].join(SEPARATOR))
4646

4747
var dirs = process.env.PYTHONPATH.split(SEPARATOR)
48-
t.deepEqual(dirs, [ EXPECTED_PYPATH, existingPath ])
48+
t.deepEqual(dirs, [EXPECTED_PYPATH, existingPath])
4949

5050
return SPAWN_RESULT
5151
}
@@ -57,16 +57,16 @@ test('configure PYTHONPATH with existing env of multiple dirs', function (t) {
5757

5858
var pythonDir1 = path.join('a', 'b')
5959
var pythonDir2 = path.join('b', 'c')
60-
var existingPath = [ pythonDir1, pythonDir2 ].join(SEPARATOR)
60+
var existingPath = [pythonDir1, pythonDir2].join(SEPARATOR)
6161
process.env.PYTHONPATH = existingPath
6262

6363
var prog = gyp()
6464
prog.parseArgv([])
6565
prog.spawn = function () {
66-
t.equal(process.env.PYTHONPATH, [ EXPECTED_PYPATH, existingPath ].join(SEPARATOR))
66+
t.equal(process.env.PYTHONPATH, [EXPECTED_PYPATH, existingPath].join(SEPARATOR))
6767

6868
var dirs = process.env.PYTHONPATH.split(SEPARATOR)
69-
t.deepEqual(dirs, [ EXPECTED_PYPATH, pythonDir1, pythonDir2 ])
69+
t.deepEqual(dirs, [EXPECTED_PYPATH, pythonDir1, pythonDir2])
7070

7171
return SPAWN_RESULT
7272
}

0 commit comments

Comments
 (0)