Skip to content

Commit 7dc2ab0

Browse files
committed
Add version-guard to silent failure on old node
1 parent 8d83230 commit 7dc2ab0

File tree

8 files changed

+15
-23
lines changed

8 files changed

+15
-23
lines changed

.github/workflows/old-test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,5 @@ jobs:
4242
run: npm install
4343

4444
- name: Test that the command line program exits cleanly.
45-
run: ./bin/cmd.js
45+
run: ./bin/cmd.cjs
4646
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')('../cli.js', 12, 22)

bin/cmd.js

-16
This file was deleted.

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)

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)