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

Require Node.js 12 and move to ESM #31

Merged
merged 3 commits into from
Feb 27, 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
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 13 additions & 11 deletions cli.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env node
'use strict';
const meow = require('meow');
const cpy = require('cpy');

import process from 'node:process';
import meow from 'meow';
import cpy from 'cpy';

const cli = meow(`
Usage
Expand All @@ -23,27 +24,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 () => {
Expand All @@ -53,7 +55,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') {
Expand Down
17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
"cpy": "cli.js"
},
"engines": {
"node": ">=8"
"node": ">=12.20"
},
"type": "module",
"scripts": {
"test": "xo && ava"
},
Expand Down Expand Up @@ -50,14 +51,14 @@
"contents"
],
"dependencies": {
"cpy": "^8.0.0",
"meow": "^6.1.1"
"cpy": "^8.1.2",
"meow": "^10.1.2"
},
"devDependencies": {
"ava": "^2.4.0",
"execa": "^1.0.0",
"path-exists": "^4.0.0",
"tempfile": "^3.0.0",
"xo": "^0.25.3"
"ava": "^4.0.1",
"execa": "^6.1.0",
"path-exists": "^5.0.0",
"tempfile": "^4.0.0",
"xo": "^0.48.0"
}
}
16 changes: 8 additions & 8 deletions test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
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';
import pathExists from 'path-exists';
import {execa} from 'execa';
import {pathExistsSync} from 'path-exists';

const read = (...args) => fs.readFileSync(path.join(...args), 'utf8');

Expand All @@ -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 => {
Expand Down Expand Up @@ -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')));
});