src: implement standard.js linting · nodejs/node-gyp@e40c99e · GitHub
Skip to content

Commit e40c99e

Browse files
committed
src: implement standard.js linting
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: #1794 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: João Reis <reis@janeasystems.com>
1 parent 7e81270 commit e40c99e

28 files changed

Lines changed: 746 additions & 668 deletions

.eslintrc.yaml

Lines changed: 0 additions & 6 deletions
This file was deleted.

.jshintrc

Lines changed: 0 additions & 7 deletions
This file was deleted.

bin/node-gyp.js

Lines changed: 15 additions & 14 deletions

lib/build.js

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1+
'use strict'
12

2-
module.exports = exports = build
3-
4-
var fs = require('graceful-fs')
5-
, path = require('path')
6-
, glob = require('glob')
7-
, log = require('npmlog')
8-
, which = require('which')
9-
, win = process.platform === 'win32'
3+
const fs = require('graceful-fs')
4+
const path = require('path')
5+
const glob = require('glob')
6+
const log = require('npmlog')
7+
const which = require('which')
8+
const win = process.platform === 'win32'
109

1110
exports.usage = 'Invokes `' + (win ? 'msbuild' : 'make') + '` and builds the module'
1211

@@ -17,18 +16,19 @@ function build (gyp, argv, callback) {
1716
} else if (process.platform.indexOf('bsd') !== -1) {
1817
platformMake = 'gmake'
1918
} else if (win && argv.length > 0) {
20-
argv = argv.map(function(target) {
19+
argv = argv.map(function (target) {
2120
return '/t:' + target
2221
})
2322
}
2423

2524
var makeCommand = gyp.opts.make || process.env.MAKE || platformMake
26-
, command = win ? 'msbuild' : makeCommand
27-
, jobs = gyp.opts.jobs || process.env.JOBS
28-
, buildType
29-
, config
30-
, arch
31-
, nodeDir
25+
var command = win ? 'msbuild' : makeCommand
26+
var jobs = gyp.opts.jobs || process.env.JOBS
27+
var buildType
28+
var config
29+
var arch
30+
var nodeDir
31+
var guessedSolution
3232

3333
loadConfigGypi()
3434

@@ -38,16 +38,17 @@ function build (gyp, argv, callback) {
3838

3939
function loadConfigGypi () {
4040
var configPath = path.resolve('build', 'config.gypi')
41+
4142
fs.readFile(configPath, 'utf8', function (err, data) {
4243
if (err) {
43-
if (err.code == 'ENOENT') {
44+
if (err.code === 'ENOENT') {
4445
callback(new Error('You must run `node-gyp configure` first!'))
4546
} else {
4647
callback(err)
4748
}
4849
return
4950
}
50-
config = JSON.parse(data.replace(/\#.+\n/, ''))
51+
config = JSON.parse(data.replace(/#.+\n/, ''))
5152

5253
// get the 'arch', 'buildType', and 'nodeDir' vars from the config
5354
buildType = config.target_defaults.default_configuration
@@ -79,7 +80,9 @@ function build (gyp, argv, callback) {
7980

8081
function findSolutionFile () {
8182
glob('build/*.sln', function (err, files) {
82-
if (err) return callback(err)
83+
if (err) {
84+
return callback(err)
85+
}
8386
if (files.length === 0) {
8487
return callback(new Error('Could not find *.sln file. Did you run "configure"?'))
8588
}
@@ -124,9 +127,12 @@ function build (gyp, argv, callback) {
124127
function doBuild () {
125128
// Enable Verbose build
126129
var verbose = log.levels[log.level] <= log.levels.verbose
130+
var j
131+
127132
if (!win && verbose) {
128133
argv.push('V=1')
129134
}
135+
130136
if (win && !verbose) {
131137
argv.push('/clp:Verbosity=minimal')
132138
}
@@ -142,12 +148,12 @@ function build (gyp, argv, callback) {
142148
// Since there are many ways to state '32-bit Intel', default to it.
143149
// N.B. msbuild's Condition string equality tests are case-insensitive.
144150
var archLower = arch.toLowerCase()
145-
var p = archLower === 'x64' ? 'x64' :
146-
(archLower === 'arm' ? 'ARM' :
147-
(archLower === 'arm64' ? 'ARM64' : 'Win32'))
151+
var p = archLower === 'x64' ? 'x64'
152+
: (archLower === 'arm' ? 'ARM'
153+
: (archLower === 'arm64' ? 'ARM64' : 'Win32'))
148154
argv.push('/p:Configuration=' + buildType + ';Platform=' + p)
149155
if (jobs) {
150-
var j = parseInt(jobs, 10)
156+
j = parseInt(jobs, 10)
151157
if (!isNaN(j) && j > 0) {
152158
argv.push('/m:' + j)
153159
} else if (jobs.toUpperCase() === 'MAX') {
@@ -160,7 +166,7 @@ function build (gyp, argv, callback) {
160166
argv.push('-C')
161167
argv.push('build')
162168
if (jobs) {
163-
var j = parseInt(jobs, 10)
169+
j = parseInt(jobs, 10)
164170
if (!isNaN(j) && j > 0) {
165171
argv.push('--jobs')
166172
argv.push(j)
@@ -174,7 +180,7 @@ function build (gyp, argv, callback) {
174180
if (win) {
175181
// did the user specify their own .sln file?
176182
var hasSln = argv.some(function (arg) {
177-
return path.extname(arg) == '.sln'
183+
return path.extname(arg) === '.sln'
178184
})
179185
if (!hasSln) {
180186
argv.unshift(gyp.opts.solution || guessedSolution)
@@ -195,3 +201,5 @@ function build (gyp, argv, callback) {
195201
callback()
196202
}
197203
}
204+
205+
module.exports = build

lib/clean.js

Lines changed: 6 additions & 6 deletions

0 commit comments

Comments
 (0)