Skip to content

Commit 75fed1f

Browse files
committed
style: fix
1 parent 7b5cb3e commit 75fed1f

File tree

6 files changed

+1030
-719
lines changed

6 files changed

+1030
-719
lines changed

index.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ function lifecycle (pkg, stage, wd, opts) {
111111
function lifecycle_ (pkg, stage, wd, opts, env, cb) {
112112
env[PATH] = extendPath(wd, env[PATH], path.join(__dirname, 'node-gyp-bin'), opts)
113113

114-
let packageLifecycle = pkg.scripts && pkg.scripts.hasOwnProperty(stage)
114+
let packageLifecycle = pkg.scripts && Object.prototype.hasOwnProperty.call(pkg.scripts, stage)
115115

116116
if (opts.ignoreScripts) {
117117
opts.log.info('lifecycle', logid(pkg, stage), 'ignored because ignore-scripts is set to true', pkg._id)
@@ -219,8 +219,8 @@ function runCmd_ (cmd, pkg, env, wd, opts, stage, unsafe, uid, gid, cb_) {
219219

220220
const conf = {
221221
cwd: wd,
222-
env: env,
223-
stdio: opts.stdio || [ 0, 1, 2 ]
222+
env,
223+
stdio: opts.stdio || [0, 1, 2]
224224
}
225225

226226
if (!unsafe) {
@@ -262,8 +262,9 @@ function runCmd_ (cmd, pkg, env, wd, opts, stage, unsafe, uid, gid, cb_) {
262262
execute(cmd, [], execOpts)
263263
.then((code) => {
264264
opts.log.silly('lifecycle', logid(pkg, stage), 'Returned: code:', code)
265+
let er
265266
if (code) {
266-
var er = new Error(`Exit status ${code}`)
267+
er = new Error(`Exit status ${code}`)
267268
er.errno = code
268269
}
269270
procError(er)
@@ -278,12 +279,12 @@ function runCmd_ (cmd, pkg, env, wd, opts, stage, unsafe, uid, gid, cb_) {
278279
proc.on('close', (code, signal) => {
279280
opts.log.silly('lifecycle', logid(pkg, stage), 'Returned: code:', code, ' signal:', signal)
280281
let err
281-
if (signal && signal !== "SIGINT") {
282+
if (signal && signal !== 'SIGINT') {
282283
err = new PnpmError('CHILD_PROCESS_FAILED', `Command failed with signal "${signal}"`)
283284
process.kill(process.pid, signal)
284285
} else if (code) {
285-
err = new PnpmError('CHILD_PROCESS_FAILED', `Exit status ${code}`)
286-
err.errno = code
286+
err = new PnpmError('CHILD_PROCESS_FAILED', `Exit status ${code}`)
287+
err.errno = code
287288
}
288289
procError(err)
289290
})
@@ -347,15 +348,15 @@ function makeEnv (data, opts, prefix, env) {
347348
prefix = prefix || 'npm_package_'
348349
if (!env) {
349350
env = {}
350-
for (var i in process.env) {
351+
for (const i in process.env) {
351352
if (!i.match(/^npm_/) && (!i.match(/^PATH$/i) || i === PATH)) {
352353
env[i] = process.env[i]
353354
}
354355
}
355356

356357
// express and others respect the NODE_ENV value.
357358
if (opts.production) env.NODE_ENV = 'production'
358-
} else if (!data.hasOwnProperty('_lifecycleEnv')) {
359+
} else if (!Object.prototype.hasOwnProperty.call(data, '_lifecycleEnv')) {
359360
Object.defineProperty(data, '_lifecycleEnv',
360361
{
361362
value: env,
@@ -366,7 +367,7 @@ function makeEnv (data, opts, prefix, env) {
366367

367368
if (opts.nodeOptions) env.NODE_OPTIONS = opts.nodeOptions
368369

369-
for (i in data) {
370+
for (const i in data) {
370371
if (i.charAt(0) !== '_') {
371372
const envKey = (prefix + i).replace(/[^a-zA-Z0-9_]/g, '_')
372373
if (i === 'readme') {

lib/extendPath.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
const path = require('path');
1+
const fs = require('fs')
2+
const path = require('path')
23
const which = require('which')
34

45
module.exports = (wd, originalPath, nodeGyp, opts) => {
@@ -23,7 +24,7 @@ module.exports = (wd, originalPath, nodeGyp, opts) => {
2324

2425
if (originalPath) pathArr.push(originalPath)
2526
return pathArr.join(process.platform === 'win32' ? ';' : ':')
26-
};
27+
}
2728

2829
function shouldPrependCurrentNodeDirToPATH (opts) {
2930
const cfgsetting = opts.scriptsPrependNodePath
@@ -58,4 +59,3 @@ function shouldPrependCurrentNodeDirToPATH (opts) {
5859

5960
return isDifferentNodeInPath
6061
}
61-

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@
4444
},
4545
"devDependencies": {
4646
"nyc": "15.1.0",
47-
"sinon": "10.0.0",
48-
"standard": "12.0.1",
47+
"sinon": "16.1.0",
48+
"standard": "17.1.0",
4949
"standard-version": "9.1.1",
5050
"tap": "15.1.2",
5151
"weallbehave": "1.2.0",

0 commit comments

Comments
 (0)