Skip to content

Commit

Permalink
chore: use neostandard
Browse files Browse the repository at this point in the history
  • Loading branch information
voxpelli committed Jul 2, 2024
1 parent 6be8fff commit e8890de
Show file tree
Hide file tree
Showing 15 changed files with 36 additions and 39 deletions.
3 changes: 0 additions & 3 deletions bin/common/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
// ------------------------------------------------------------------------------
// Public Interface
// ------------------------------------------------------------------------------
/* eslint-disable no-process-exit */

module.exports = function bootstrap (name) {
const argv = process.argv.slice(2)
Expand Down Expand Up @@ -47,5 +46,3 @@ module.exports = function bootstrap (name) {
)
}
}

/* eslint-enable */
4 changes: 0 additions & 4 deletions bin/common/parse-cli-args.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
*/
'use strict'

/* eslint-disable no-process-env */

// ------------------------------------------------------------------------------
// Helpers
// ------------------------------------------------------------------------------
Expand Down Expand Up @@ -243,5 +241,3 @@ function parseCLIArgsCore (set, args) {
module.exports = function parseCLIArgs (args, initialValues, options) {
return parseCLIArgsCore(new ArgumentSet(initialValues, options), args)
}

/* eslint-enable */
4 changes: 1 addition & 3 deletions bin/npm-run-all/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ module.exports = function npmRunAll (args, stdout, stderr) {
arguments: argv.rest,
race: group.parallel && argv.race,
npmPath: argv.npmPath,
aggregateOutput: group.parallel && argv.aggregateOutput
aggregateOutput: group.parallel && argv.aggregateOutput,
}
))
},
Expand All @@ -61,14 +61,12 @@ module.exports = function npmRunAll (args, stdout, stderr) {

if (!argv.silent) {
promise.catch(err => {
// eslint-disable-next-line no-console
console.error('ERROR:', err.message)
})
}

return promise
} catch (err) {
// eslint-disable-next-line no-console
console.error('ERROR:', err.message)

return Promise.reject(err)
Expand Down
4 changes: 1 addition & 3 deletions bin/run-p/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,18 @@ module.exports = function npmRunAll (args, stdout, stderr) {
arguments: argv.rest,
race: argv.race,
npmPath: argv.npmPath,
aggregateOutput: argv.aggregateOutput
aggregateOutput: argv.aggregateOutput,
}
)

if (!argv.silent) {
promise.catch(err => {
// eslint-disable-next-line no-console
console.error('ERROR:', err.message)
})
}

return promise
} catch (err) {
// eslint-disable-next-line no-console
console.error('ERROR:', err.message)

return Promise.reject(err)
Expand Down
4 changes: 1 addition & 3 deletions bin/run-s/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,18 @@ module.exports = function npmRunAll (args, stdout, stderr) {
packageConfig: argv.packageConfig,
silent: argv.silent,
arguments: argv.rest,
npmPath: argv.npmPath
npmPath: argv.npmPath,
}
)

if (!argv.silent) {
promise.catch(err => {
// eslint-disable-next-line no-console
console.error('ERROR:', err.message)
})
}

return promise
} catch (err) {
// eslint-disable-next-line no-console
console.error('ERROR:', err.message)

return Promise.reject(err)
Expand Down
9 changes: 9 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict'

module.exports = [
...require('neostandard')({
env: ['mocha'],
ignores: require('neostandard').resolveIgnoresFromGitignore(),
ts: true,
}),
]
6 changes: 3 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ function maxLength (length, name) {
* @returns {Promise}
* A promise object which becomes fullfilled when all npm-scripts are completed.
*/
module.exports = function npmRunAll (patternOrPatterns, options) { // eslint-disable-line complexity
module.exports = function npmRunAll (patternOrPatterns, options) {
const stdin = (options && options.stdin) || null
const stdout = (options && options.stdout) || null
const stderr = (options && options.stderr) || null
Expand Down Expand Up @@ -290,14 +290,14 @@ module.exports = function npmRunAll (patternOrPatterns, options) { // eslint-dis
enabled: printLabel,
width: labelWidth,
lastPrefix: null,
lastIsLinebreak: true
lastIsLinebreak: true,
},
printName,
packageInfo: x.packageInfo,
race,
maxParallel,
npmPath,
aggregateOutput
aggregateOutput,
})
})
} catch (err) {
Expand Down
2 changes: 1 addition & 1 deletion lib/read-package-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ module.exports = function readPackageJson () {
const path = joinPath(process.cwd(), 'package.json')
return readPackage(path).then(body => ({
taskList: Object.keys(body.scripts || {}),
packageInfo: { path, body }
packageInfo: { path, body },
}))
}
8 changes: 4 additions & 4 deletions lib/run-task.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,14 @@ module.exports = function runTask (task, options) {
const basename = path.basename(process.env.npm_execpath)
let newBasename = basename
if (basename.startsWith('npx')) {
newBasename = basename.replace('npx', 'npm') // eslint-disable-line no-process-env
newBasename = basename.replace('npx', 'npm')
} else if (basename.startsWith('pnpx')) {
newBasename = basename.replace('pnpx', 'pnpm') // eslint-disable-line no-process-env
newBasename = basename.replace('pnpx', 'pnpm')
}

npmPath = newBasename !== basename
? path.join(path.dirname(process.env.npm_execpath), newBasename)
: process.env.npm_execpath // eslint-disable-line no-process-env
: process.env.npm_execpath
}

const npmPathIsJs = typeof npmPath === 'string' && /\.(c|m)?js/.test(path.extname(npmPath))
Expand All @@ -191,7 +191,7 @@ module.exports = function runTask (task, options) {
}
}

const isYarn = process.env.npm_config_user_agent && process.env.npm_config_user_agent.startsWith('yarn') // eslint-disable-line no-process-env
const isYarn = process.env.npm_config_user_agent && process.env.npm_config_user_agent.startsWith('yarn')

const spawnArgs = ['run']

Expand Down
4 changes: 2 additions & 2 deletions lib/run-tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const signals = {
SIGTTIN: 21,
SIGTTOU: 22,
SIGUSR1: 30,
SIGUSR2: 31
SIGUSR2: 31,
}

/**
Expand Down Expand Up @@ -142,7 +142,7 @@ module.exports = function runTasks (tasks, options) {
const originalOutputStream = options.stdout
const optionsClone = Object.assign({}, options)
const writer = new MemoryStream(null, {
readable: false
readable: false,
})

if (options.aggregateOutput) {
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"_mocha": "mocha --timeout 120000",
"clean": "rm -rf coverage jsdoc \"test-workspace/{build,test.txt}\"",
"docs": "jsdoc -c jsdoc.json",
"lint": "standard",
"lint": "eslint",
"pretest": "node scripts/make-slink.js && npm run lint",
"test": "c8 npm run _mocha",
"watch": "npm run _mocha -- --watch --growl",
Expand All @@ -37,12 +37,13 @@
"devDependencies": {
"auto-changelog": "^2.2.0",
"c8": "^10.0.0",
"eslint": "^9.6.0",
"fs-extra": "^11.1.0",
"gh-release": "^7.0.0",
"jsdoc": "^4.0.0",
"mocha": "^10.0.0",
"neostandard": "^0.11.0",
"p-queue": "^8.0.1",
"standard": "^17.1.0",
"yarn": "^1.12.3"
},
"repository": {
Expand Down
4 changes: 2 additions & 2 deletions test/aggregate-output.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('[aggregated-output] npm-run-all', () => {
createExpectedOutput('second'),
createExpectedOutput('third'),
createExpectedOutput('first'),
''
'',
].join('\n')

let stdout = null
Expand Down Expand Up @@ -107,7 +107,7 @@ describe('[aggregated-output] npm-run-all', () => {
'test-task:delayed first 5000',
'test-task:delayed second 1000',
'test-task:delayed third 3000',
'--silent', '--aggregate-output'
'--silent', '--aggregate-output',
],
stdout
)
Expand Down
4 changes: 2 additions & 2 deletions test/bin/run-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function runMocha (filePath, workspacePath) {
failing,
id: path.basename(filePath, '.js'),
passing,
text
text,
})
})
cp.on('error', reject)
Expand Down Expand Up @@ -165,5 +165,5 @@ async function runMochaWithWorkspace (filePath) {
process.stdout.write(`\n\nTOTAL: passing ${passing} failing ${failing} (${durationToText(process.uptime() - startInSec)})\n\n`)
})().catch(error => {
process.stderr.write(`\n\n${error.stack}\n\n`)
process.exit(1) // eslint-disable-line no-process-exit
process.exit(1)
})
6 changes: 3 additions & 3 deletions test/mixed.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('[mixed] npm-run-all', () => {
await runAll([
'test-task:append a',
'-p', 'test-task:append b', 'test-task:append c',
'-s', 'test-task:append d', 'test-task:append e'
'-s', 'test-task:append d', 'test-task:append e',
])
assert(
result() === 'aabcbcddee' ||
Expand All @@ -43,7 +43,7 @@ describe('[mixed] npm-run-all', () => {
it("should run a mix of sequential and parallel tasks (doesn't have the default group):", async () => {
await runAll([
'-p', 'test-task:append b', 'test-task:append c',
'-s', 'test-task:append d', 'test-task:append e'
'-s', 'test-task:append d', 'test-task:append e',
])
assert(
result() === 'bcbcddee' ||
Expand All @@ -58,6 +58,6 @@ describe('[mixed] npm-run-all', () => {
'test-task:append a',
'-p', 'test-task:append b', 'test-task:append c',
'-s', 'test-task:append d', 'test-task:append e',
'-r'
'-r',
]))
})
8 changes: 4 additions & 4 deletions test/print-label.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('[print-label] npm-run-all', () => {
'[test-task:echo abc] ',
'[test-task:echo abc] ',
'[test-task:echo abc] ',
'[test-task:echo abc] abc'
'[test-task:echo abc] abc',
].join('\n')

it('Node API', async () => {
Expand Down Expand Up @@ -134,7 +134,7 @@ describe('[print-label] npm-run-all', () => {
'[test-task:echo ab ] ',
'[test-task:echo ab ] ',
'[test-task:echo ab ] ',
'[test-task:echo ab ] ab'
'[test-task:echo ab ] ab',
].join('\n')

it('Node API', async () => {
Expand Down Expand Up @@ -172,12 +172,12 @@ describe('[print-label] npm-run-all', () => {
'\n[test-task:echo ab ] ',
'\n[test-task:echo ab ] ab',
'\n[test-task:echo abcd] ',
'\n[test-task:echo abcd] abcd'
'\n[test-task:echo abcd] abcd',
]
const UNEXPECTED_PATTERNS = [
/aab(cd)?/,
/ab(cd)?a\b/,
/\n\n/
/\n\n/,
]

it('Node API', async () => {
Expand Down

0 comments on commit e8890de

Please sign in to comment.