Skip to content

Commit 6dd2162

Browse files
authored
fix: silent exit on unsupported node.js versions (#1829)
2 parents 8d83230 + f635e4e commit 6dd2162

File tree

10 files changed

+20
-36
lines changed

10 files changed

+20
-36
lines changed

.github/workflows/old-test.yml

+3-11
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919

2020
strategy:
2121
matrix:
22-
node-version: [0.10.48]
22+
node-version: [0.10.48, 4]
2323

2424
steps:
2525
- name: Checkout project
@@ -30,17 +30,9 @@ jobs:
3030
with:
3131
node-version: ${{ matrix.node-version }}
3232

33-
- name: Cache Node dependencies
34-
uses: actions/cache@v3
35-
with:
36-
path: ~/.npm
37-
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
38-
restore-keys: |
39-
${{ runner.os }}-node-
40-
4133
- name: Install dependencies
42-
run: npm install
34+
run: npm install --production
4335

4436
- name: Test that the command line program exits cleanly.
45-
run: ./bin/cmd.js
37+
run: ./bin/cmd.cjs
4638
shell: bash

bin/cmd.cjs

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env node
2+
3+
require('version-guard')('../lib/cli.js', 12, 22)

bin/cmd.js

-16
This file was deleted.

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*! standard. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
22
import { StandardEngine } from 'standard-engine'
3-
import options from './options.js'
3+
import options from './lib/options.js'
44

55
export default new StandardEngine(options)

lib/cli.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { cli } from 'standard-engine'
2+
import options from './options.js'
3+
4+
cli(options)

options.js lib/options.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { fileURLToPath } from 'node:url'
33
import eslint from 'eslint'
44

55
// eslintConfig.overrideConfigFile have problem reading URLs and file:///
6-
const overrideConfigFile = fileURLToPath(new URL('./eslintrc.json', import.meta.url))
7-
const pkgURL = new URL('./package.json', import.meta.url)
6+
const overrideConfigFile = fileURLToPath(new URL('../eslintrc.json', import.meta.url))
7+
const pkgURL = new URL('../package.json', import.meta.url)
88
const pkgJSON = readFileSync(pkgURL, { encoding: 'utf-8' })
99
const pkg = JSON.parse(pkgJSON)
1010

package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"url": "https://feross.org"
99
},
1010
"bin": {
11-
"standard": "bin/cmd.js"
11+
"standard": "bin/cmd.cjs"
1212
},
1313
"type": "module",
1414
"bugs": {
@@ -22,7 +22,8 @@
2222
"eslint-plugin-n": "^15.1.0",
2323
"eslint-plugin-promise": "^6.0.0",
2424
"eslint-plugin-react": "^7.28.0",
25-
"standard-engine": "^15.0.0"
25+
"standard-engine": "^15.0.0",
26+
"version-guard": "^1.1.0"
2627
},
2728
"devDependencies": {
2829
"cross-spawn": "^7.0.3",
@@ -70,7 +71,7 @@
7071
},
7172
"scripts": {
7273
"test": "npm run test-internal && npm run test-external",
73-
"test-internal": "./bin/cmd.js --verbose && tape test/*.js",
74+
"test-internal": "./bin/cmd.cjs --verbose && tape test/*.js",
7475
"test-external": "tape test/external/*.js",
7576
"update-authors": "./tools/update-authors.sh && hallmark --fix AUTHORS.md"
7677
},

test/api.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import standard from '../index.js'
33

44
test('api: lintFiles', async (t) => {
55
t.plan(2)
6-
const [result] = await standard.lintFiles(['bin/cmd.js'])
6+
const [result] = await standard.lintFiles(['bin/cmd.cjs'])
77
t.equal(typeof result, 'object', 'result is an object')
88
t.equal(result.errorCount, 0)
99
})

test/cmd.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { fileURLToPath } from 'node:url'
22
import test from 'tape'
33
import crossSpawn from 'cross-spawn'
44

5-
const CMD_PATH = fileURLToPath(new URL('../bin/cmd.js', import.meta.url))
5+
const CMD_PATH = fileURLToPath(new URL('../bin/cmd.cjs', import.meta.url))
66

77
test('command line usage: --help', t => {
88
t.plan(1)

test/external/clone.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const testPkgs = JSON.parse(json)
2020

2121
const GIT = 'git'
2222
const NPM = 'npm'
23-
const STANDARD = fileURLToPath(new URL('../../bin/cmd.js', import.meta.url))
23+
const STANDARD = fileURLToPath(new URL('../../bin/cmd.cjs', import.meta.url))
2424
const TMP = new URL('../../tmp/', import.meta.url)
2525
const PARALLEL_LIMIT = Math.ceil(cpus().length / 2)
2626

0 commit comments

Comments
 (0)