Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test of silent exit on unsupported node.js versions #1829

Merged
merged 5 commits into from
Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 3 additions & 11 deletions .github/workflows/old-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

strategy:
matrix:
node-version: [0.10.48]
node-version: [0.10.48, 4]

steps:
- name: Checkout project
Expand All @@ -30,17 +30,9 @@ jobs:
with:
node-version: ${{ matrix.node-version }}

- name: Cache Node dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package.json') }}
restore-keys: |
${{ runner.os }}-node-

- name: Install dependencies
run: npm install
run: npm install --production

- name: Test that the command line program exits cleanly.
run: ./bin/cmd.js
run: ./bin/cmd.cjs
shell: bash
3 changes: 3 additions & 0 deletions bin/cmd.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env node

require('version-guard')('../lib/cli.js', 12, 22)
theoludwig marked this conversation as resolved.
Show resolved Hide resolved
16 changes: 0 additions & 16 deletions bin/cmd.js

This file was deleted.

2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*! standard. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
import { StandardEngine } from 'standard-engine'
import options from './options.js'
import options from './lib/options.js'

export default new StandardEngine(options)
4 changes: 4 additions & 0 deletions lib/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { cli } from 'standard-engine'
import options from './options.js'

cli(options)
4 changes: 2 additions & 2 deletions options.js → lib/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { fileURLToPath } from 'node:url'
import eslint from 'eslint'

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

Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"url": "https://feross.org"
},
"bin": {
"standard": "bin/cmd.js"
"standard": "bin/cmd.cjs"
},
"type": "module",
"bugs": {
Expand All @@ -22,7 +22,8 @@
"eslint-plugin-n": "^15.1.0",
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-react": "^7.28.0",
"standard-engine": "^15.0.0"
"standard-engine": "^15.0.0",
"version-guard": "^1.1.0"
},
"devDependencies": {
"cross-spawn": "^7.0.3",
Expand Down Expand Up @@ -70,7 +71,7 @@
},
"scripts": {
"test": "npm run test-internal && npm run test-external",
"test-internal": "./bin/cmd.js --verbose && tape test/*.js",
"test-internal": "./bin/cmd.cjs --verbose && tape test/*.js",
"test-external": "tape test/external/*.js",
"update-authors": "./tools/update-authors.sh && hallmark --fix AUTHORS.md"
},
Expand Down
2 changes: 1 addition & 1 deletion test/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import standard from '../index.js'

test('api: lintFiles', async (t) => {
t.plan(2)
const [result] = await standard.lintFiles(['bin/cmd.js'])
const [result] = await standard.lintFiles(['bin/cmd.cjs'])
t.equal(typeof result, 'object', 'result is an object')
t.equal(result.errorCount, 0)
})
Expand Down
2 changes: 1 addition & 1 deletion test/cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { fileURLToPath } from 'node:url'
import test from 'tape'
import crossSpawn from 'cross-spawn'

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

test('command line usage: --help', t => {
t.plan(1)
Expand Down
2 changes: 1 addition & 1 deletion test/external/clone.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const testPkgs = JSON.parse(json)

const GIT = 'git'
const NPM = 'npm'
const STANDARD = fileURLToPath(new URL('../../bin/cmd.js', import.meta.url))
const STANDARD = fileURLToPath(new URL('../../bin/cmd.cjs', import.meta.url))
const TMP = new URL('../../tmp/', import.meta.url)
const PARALLEL_LIMIT = Math.ceil(cpus().length / 2)

Expand Down