Skip to content

Commit 1080f4f

Browse files
committed
Merge branch 'esm'
2 parents af75f95 + 8f4f68d commit 1080f4f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+601
-485
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
fail-fast: false
3333
matrix:
3434
os: [ubuntu-latest, windows-latest, macos-latest]
35-
node: ['20', 'lts/*', '23']
35+
node: ['20', '22', '24']
3636

3737
steps:
3838
- uses: actions/checkout@v4
@@ -41,7 +41,7 @@ jobs:
4141
with:
4242
node-version: ${{ matrix.node }}
4343
- run: npm i
44-
- run: npm run test
44+
- run: npm run test:node-test
4545
- uses: codecov/codecov-action@v5
4646
if: ${{ github.event_name == 'pull_request' }}
4747
with:

.knip.jsonc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"$schema": "https://unpkg.com/knip@5/schema.json",
3-
"entry": ["lib/index.js", "bin/*/*.js", "test-workspace/tasks/*.js"],
3+
"entry": ["lib/cjs.cjs", "lib/esm.mjs", "bin/*/*.js", "test-workspace/tasks/*.cjs"],
44
"ignoreDependencies": ["yarn", "spec"]
55
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ $ npm install npm-run-all2 --save-dev
3030
$ yarn add npm-run-all2 --dev
3131
```
3232

33-
- It requires `Node@>=14`. It may work on older versions of Node, but no guarantees are given.
33+
- It requires `Node@>=20`. It may work on older versions of Node, but no guarantees are given.
3434

3535
## 📖 Usage
3636

bin/common/bootstrap.js

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,38 @@
33
* @copyright 2016 Toru Nagashima. All rights reserved.
44
* See LICENSE file in root directory for full license.
55
*/
6-
'use strict'
76

87
// ------------------------------------------------------------------------------
98
// Public Interface
109
// ------------------------------------------------------------------------------
1110

12-
module.exports = function bootstrap (name) {
11+
export default async function bootstrap (name) {
1312
const argv = process.argv.slice(2)
1413

1514
switch (argv[0]) {
1615
case undefined:
1716
case '-h':
18-
case '--help':
19-
return require(`../${name}/help`)(process.stdout)
17+
case '--help': {
18+
const { default: help } = await import(`../${name}/help.js`)
19+
return help(process.stdout)
20+
}
2021

2122
case '-v':
22-
case '--version':
23-
return require('./version')(process.stdout)
23+
case '--version': {
24+
const { default: version } = await import('./version.js')
25+
return version(process.stdout)
26+
}
2427

25-
default:
28+
default: {
2629
// https://github.com/mysticatea/npm-run-all/issues/105
2730
// Avoid MaxListenersExceededWarnings.
2831
process.stdout.setMaxListeners(0)
2932
process.stderr.setMaxListeners(0)
3033
process.stdin.setMaxListeners(0)
3134

3235
// Main
33-
return require(`../${name}/main`)(
36+
const { default: main } = await import(`../${name}/main.js`)
37+
return main(
3438
argv,
3539
process.stdout,
3640
process.stderr
@@ -44,5 +48,6 @@ module.exports = function bootstrap (name) {
4448
process.exit(1)
4549
}
4650
)
51+
}
4752
}
4853
}

bin/common/parse-cli-args.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* @copyright 2016 Toru Nagashima. All rights reserved.
44
* See LICENSE file in root directory for full license.
55
*/
6-
'use strict'
76

87
// ------------------------------------------------------------------------------
98
// Helpers
@@ -238,6 +237,6 @@ function parseCLIArgsCore (set, args) {
238237
* @param {boolean} options.singleMode - The flag to be single group mode.
239238
* @returns {ArgumentSet} The parsed CLI arguments.
240239
*/
241-
module.exports = function parseCLIArgs (args, initialValues, options) {
240+
export default function parseCLIArgs (args, initialValues, options) {
242241
return parseCLIArgsCore(new ArgumentSet(initialValues, options), args)
243242
}

bin/common/version.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,28 @@
33
* @copyright 2016 Toru Nagashima. All rights reserved.
44
* See LICENSE file in root directory for full license.
55
*/
6-
'use strict'
76

87
// ------------------------------------------------------------------------------
98
// Public Interface
109
// ------------------------------------------------------------------------------
1110

11+
import { readFile } from 'node:fs/promises'
12+
import { resolve } from 'node:path'
13+
14+
const __dirname = import.meta.dirname
15+
1216
/**
1317
* Print a version text.
1418
*
1519
* @param {stream.Writable} output - A writable stream to print.
1620
* @returns {Promise} Always a fulfilled promise.
1721
* @private
1822
*/
19-
module.exports = function printVersion (output) {
20-
const version = require('../../package.json').version
23+
export default async function printVersion (output) {
24+
const packageJson = JSON.parse(
25+
await readFile(resolve(__dirname, '../../package.json'), 'utf8')
26+
)
27+
const version = packageJson.version
2128

2229
output.write(`v${version}\n`)
2330

bin/npm-run-all/help.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* @copyright 2015 Toru Nagashima. All rights reserved.
44
* See LICENSE file in root directory for full license.
55
*/
6-
'use strict'
76

87
// ------------------------------------------------------------------------------
98
// Public Interface
@@ -16,7 +15,7 @@
1615
* @returns {Promise} Always a fulfilled promise.
1716
* @private
1817
*/
19-
module.exports = function printHelp (output) {
18+
export default function printHelp (output) {
2019
output.write(`
2120
Usage:
2221
$ npm-run-all [--help | -h | --version | -v]

bin/npm-run-all/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
* @copyright 2015 Toru Nagashima. All rights reserved.
55
* See LICENSE file in root directory for full license.
66
*/
7-
'use strict'
87

98
// ------------------------------------------------------------------------------
109
// Main
1110
// ------------------------------------------------------------------------------
1211

13-
require('../common/bootstrap')('npm-run-all')
12+
import bootstrap from '../common/bootstrap.js'
13+
14+
bootstrap('npm-run-all')

bin/npm-run-all/main.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33
* @copyright 2015 Toru Nagashima. All rights reserved.
44
* See LICENSE file in root directory for full license.
55
*/
6-
'use strict'
76

87
// ------------------------------------------------------------------------------
98
// Requirements
109
// ------------------------------------------------------------------------------
1110

12-
const runAll = require('../../lib')
13-
const parseCLIArgs = require('../common/parse-cli-args')
11+
import runAll from 'npm-run-all2'
12+
import parseCLIArgs from '../common/parse-cli-args.js'
1413

1514
// ------------------------------------------------------------------------------
1615
// Public Interface
@@ -25,7 +24,7 @@ const parseCLIArgs = require('../common/parse-cli-args')
2524
* @returns {Promise} A promise which comes to be fulfilled when all npm-scripts are completed.
2625
* @private
2726
*/
28-
module.exports = function npmRunAll (args, stdout, stderr) {
27+
export default function npmRunAll (args, stdout, stderr) {
2928
try {
3029
const stdin = process.stdin
3130
const argv = parseCLIArgs(args)

bin/run-p/help.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* @copyright 2016 Toru Nagashima. All rights reserved.
44
* See LICENSE file in root directory for full license.
55
*/
6-
'use strict'
76

87
// ------------------------------------------------------------------------------
98
// Public Interface
@@ -16,7 +15,7 @@
1615
* @returns {Promise} Always a fulfilled promise.
1716
* @private
1817
*/
19-
module.exports = function printHelp (output) {
18+
export default function printHelp (output) {
2019
output.write(`
2120
Usage:
2221
$ run-p [--help | -h | --version | -v]

0 commit comments

Comments
 (0)