Skip to content

Commit

Permalink
Require Node.js 18 (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
tommy-mitchell committed Jan 28, 2024
1 parent 5ed811e commit f6a9d04
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 19 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ jobs:
fail-fast: false
matrix:
node-version:
- 16
- 18
- 20
- 21
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm test
- run: script -e -c "npm test"
4 changes: 1 addition & 3 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,5 @@ if (!input && process.stdin.isTTY) {
if (input) {
init(input);
} else {
(async () => {
init(await getStdin());
})();
init(await getStdin());
}
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"strip-ansi": "./cli.js"
},
"engines": {
"node": ">=12.17"
"node": ">=18"
},
"scripts": {
"test": "xo && ava"
Expand Down Expand Up @@ -51,12 +51,12 @@
],
"dependencies": {
"get-stdin": "^9.0.0",
"meow": "^10.1.1",
"strip-ansi": "^7.0.1"
"meow": "^13.1.0",
"strip-ansi": "^7.1.0"
},
"devDependencies": {
"ava": "^3.15.0",
"execa": "^5.1.1",
"xo": "^0.44.0"
"ava": "^6.1.0",
"execa": "^8.0.1",
"xo": "^0.56.0"
}
}
23 changes: 17 additions & 6 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
import test from 'ava';
import execa from 'execa';
import {execa} from 'execa';

const fixture = '\u001B[0m\u001B[4m\u001B[42m\u001B[31mfoo\u001B[39m\u001B[49m\u001B[24mfoo\u001B[0m';

test('main', async t => {
const {stdout} = await execa('./cli.js', ['--version']);
t.true(stdout.length > 0);
const {stdout} = await execa('./cli.js', [fixture]);
t.is(stdout, 'foofoo');
});

test('stdin', async t => {
const {stdout} = await execa('./cli.js', {
input: '\u001B[0m\u001B[4m\u001B[42m\u001B[31mfoo\u001B[39m\u001B[49m\u001B[24mfoo\u001B[0m',
});
const {stdout} = await execa('./cli.js', {input: fixture});
t.is(stdout, 'foofoo');
});

// NOTE: This test assumes AVA is run in a TTY environment
test('no input', async t => {
/** @type {import('execa').ExecaError} */
const error = await t.throwsAsync(execa('./cli.js', {stdin: 'inherit'}));

t.like(error, {
stderr: 'Input required',
exitCode: 1,
});
});

0 comments on commit f6a9d04

Please sign in to comment.