From 3c3e04d161fe18eaa56314fbf92e63abb3533f98 Mon Sep 17 00:00:00 2001 From: Anton Golub Date: Fri, 16 Jul 2021 21:38:41 +0300 Subject: [PATCH 1/3] ci: drop out of maintenance Node.js v8, v10, add v16 to test matrix --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 18531b3..9f06ce6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,10 +10,10 @@ jobs: fail-fast: false matrix: node-version: + - 16 - 14 - 12 - - 10 - - 8 + steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v1 From fdc4e7a4b3a092061906912ba440453f32f7fd9d Mon Sep 17 00:00:00 2001 From: Anton Golub Date: Fri, 16 Jul 2021 21:59:36 +0300 Subject: [PATCH 2/3] feat: move to esm BREAKING_CHANGE: require Node.js >= 12.20 --- cli.js | 23 ++++++++++++----------- package.json | 15 ++++++++------- test.js | 8 ++++---- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/cli.js b/cli.js index e11be56..a059486 100755 --- a/cli.js +++ b/cli.js @@ -1,7 +1,7 @@ #!/usr/bin/env node -'use strict'; -const meow = require('meow'); -const cpy = require('cpy'); + +import meow from 'meow'; +import cpy from 'cpy'; const cli = meow(` Usage @@ -23,27 +23,28 @@ const cli = meow(` Copy all .html files inside src folder into dist and preserve path structure $ cpy '**/*.html' '../dist/' --cwd=src --parents `, { + importMeta: import.meta, flags: { overwrite: { type: 'boolean', - default: true + default: true, }, parents: { type: 'boolean', - default: false + default: false, }, cwd: { type: 'string', - default: process.cwd() + default: process.cwd(), }, rename: { - type: 'string' + type: 'string', }, dot: { type: 'boolean', - default: false - } - } + default: false, + }, + }, }); (async () => { @@ -53,7 +54,7 @@ const cli = meow(` rename: cli.flags.rename, parents: cli.flags.parents, overwrite: cli.flags.overwrite, - dot: cli.flags.dot + dot: cli.flags.dot, }); } catch (error) { if (error.name === 'CpyError') { diff --git a/package.json b/package.json index 8c7c53c..53b4bcb 100644 --- a/package.json +++ b/package.json @@ -21,8 +21,9 @@ "cpy": "cli.js" }, "engines": { - "node": ">=8" + "node": ">=12.20" }, + "type": "module", "scripts": { "test": "xo && ava" }, @@ -50,14 +51,14 @@ "contents" ], "dependencies": { - "cpy": "^8.0.0", - "meow": "^6.1.1" + "cpy": "^8.1.2", + "meow": "^10.1.0" }, "devDependencies": { - "ava": "^2.4.0", - "execa": "^1.0.0", + "ava": "^3.15.0", + "execa": "^5.1.1", "path-exists": "^4.0.0", - "tempfile": "^3.0.0", - "xo": "^0.25.3" + "tempfile": "^4.0.0", + "xo": "^0.42.0" } } diff --git a/test.js b/test.js index e99ca4b..d4b8abf 100644 --- a/test.js +++ b/test.js @@ -1,5 +1,5 @@ -import path from 'path'; -import fs from 'fs'; +import path from 'node:path'; +import fs from 'node:fs'; import test from 'ava'; import tempfile from 'tempfile'; import execa from 'execa'; @@ -12,11 +12,11 @@ test.beforeEach(t => { }); test('missing file operands', async t => { - await t.throwsAsync(execa('./cli.js'), /`source` and `destination` required/); + await t.throwsAsync(execa('./cli.js'), {message: /`source` and `destination` required/}); }); test('source file does not exist', async t => { - await t.throwsAsync(execa('./cli.js', [path.join(t.context.tmp, 'nonexistentfile'), t.context.tmp]), /nonexistentfile/); + await t.throwsAsync(execa('./cli.js', [path.join(t.context.tmp, 'nonexistentfile'), t.context.tmp]), {message: /nonexistentfile/}); }); test('cwd', async t => { From 56db7187da961ea08e63dd0963e96ba4009757a9 Mon Sep 17 00:00:00 2001 From: Anton Golub Date: Sun, 20 Feb 2022 21:38:57 +0300 Subject: [PATCH 3/3] chore: update meow to v10.1.2, update dev deps --- cli.js | 1 + package.json | 10 +++++----- test.js | 8 ++++---- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/cli.js b/cli.js index a059486..02ea2cb 100755 --- a/cli.js +++ b/cli.js @@ -1,5 +1,6 @@ #!/usr/bin/env node +import process from 'node:process'; import meow from 'meow'; import cpy from 'cpy'; diff --git a/package.json b/package.json index 53b4bcb..3804cf7 100644 --- a/package.json +++ b/package.json @@ -52,13 +52,13 @@ ], "dependencies": { "cpy": "^8.1.2", - "meow": "^10.1.0" + "meow": "^10.1.2" }, "devDependencies": { - "ava": "^3.15.0", - "execa": "^5.1.1", - "path-exists": "^4.0.0", + "ava": "^4.0.1", + "execa": "^6.1.0", + "path-exists": "^5.0.0", "tempfile": "^4.0.0", - "xo": "^0.42.0" + "xo": "^0.48.0" } } diff --git a/test.js b/test.js index d4b8abf..7cdfcd0 100644 --- a/test.js +++ b/test.js @@ -2,8 +2,8 @@ import path from 'node:path'; import fs from 'node:fs'; import test from 'ava'; import tempfile from 'tempfile'; -import execa from 'execa'; -import pathExists from 'path-exists'; +import {execa} from 'execa'; +import {pathExistsSync} from 'path-exists'; const read = (...args) => fs.readFileSync(path.join(...args), 'utf8'); @@ -71,6 +71,6 @@ test('do not copy files in the negated glob patterns', async t => { await execa('./cli.js', ['src/*.*', '!src/*.jsx', '!src/*.es2015', 'dest', '--cwd', t.context.tmp]); t.is(read(t.context.tmp, 'dest/hello.js'), 'console.log("hello");'); - t.false(pathExists.sync(path.join(t.context.tmp, 'dest/hello.jsx'))); - t.false(pathExists.sync(path.join(t.context.tmp, 'dest/hello.es2015'))); + t.false(pathExistsSync(path.join(t.context.tmp, 'dest/hello.jsx'))); + t.false(pathExistsSync(path.join(t.context.tmp, 'dest/hello.es2015'))); });