From f6a9d049aec7e59a2daad42e9bfae5dbf4325ad2 Mon Sep 17 00:00:00 2001 From: Tommy Date: Sun, 28 Jan 2024 10:38:09 -0600 Subject: [PATCH] Require Node.js 18 (#5) --- .github/workflows/main.yml | 10 ++++++---- cli.js | 4 +--- package.json | 12 ++++++------ test.js | 23 +++++++++++++++++------ 4 files changed, 30 insertions(+), 19 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 441975c..623210b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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" diff --git a/cli.js b/cli.js index 1e995b2..6e163a6 100755 --- a/cli.js +++ b/cli.js @@ -29,7 +29,5 @@ if (!input && process.stdin.isTTY) { if (input) { init(input); } else { - (async () => { - init(await getStdin()); - })(); + init(await getStdin()); } diff --git a/package.json b/package.json index a6c04fd..9cbb76e 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "strip-ansi": "./cli.js" }, "engines": { - "node": ">=12.17" + "node": ">=18" }, "scripts": { "test": "xo && ava" @@ -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" } } diff --git a/test.js b/test.js index fa6968a..7cba068 100644 --- a/test.js +++ b/test.js @@ -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, + }); +});