From a31ef1805d9ed1ef4367060621d7c0f1079e3b51 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Wed, 29 May 2019 00:24:14 +0700 Subject: [PATCH] Require Node.js 8 --- .travis.yml | 2 +- cli.js | 31 ++++++++++++++++++------------- package.json | 14 +++++++------- readme.md | 7 +------ test.js | 4 ++-- 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2ae9d62..f98fed0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: node_js node_js: + - '12' - '10' - '8' - - '6' diff --git a/cli.js b/cli.js index 3b01f70..4caf195 100755 --- a/cli.js +++ b/cli.js @@ -5,7 +5,7 @@ const cpy = require('cpy'); const cli = meow(` Usage - $ cpy ... + $ cpy Options --no-overwrite Don't overwrite the destination @@ -41,16 +41,21 @@ const cli = meow(` } }); -cpy(cli.input, cli.input.pop(), { - cwd: cli.flags.cwd, - rename: cli.flags.rename, - parents: cli.flags.parents, - overwrite: cli.flags.overwrite -}).catch(err => { - if (err.name === 'CpyError') { - console.error(err.message); - process.exit(1); - } else { - throw err; +(async () => { + try { + await cpy(cli.input, cli.input.pop(), { + cwd: cli.flags.cwd, + rename: cli.flags.rename, + parents: cli.flags.parents, + overwrite: cli.flags.overwrite + }); + } catch (error) { + if (error.name === 'CpyError') { + console.error(error.message); + process.exit(1); + } else { + throw error; + } } -}); +})(); + diff --git a/package.json b/package.json index 39acd74..c7f1429 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "cpy": "cli.js" }, "engines": { - "node": ">=6" + "node": ">=8" }, "scripts": { "test": "xo && ava" @@ -49,14 +49,14 @@ "contents" ], "dependencies": { - "cpy": "^7.0.0", + "cpy": "^7.2.0", "meow": "^5.0.0" }, "devDependencies": { - "ava": "*", - "execa": "^0.10.0", - "path-exists": "^3.0.0", - "tempfile": "^2.0.0", - "xo": "*" + "ava": "^1.4.1", + "execa": "^1.0.0", + "path-exists": "^4.0.0", + "tempfile": "^3.0.0", + "xo": "^0.24.0" } } diff --git a/readme.md b/readme.md index 64c32fc..feee2d3 100644 --- a/readme.md +++ b/readme.md @@ -24,7 +24,7 @@ $ npm install --global cpy-cli $ cpy --help Usage - $ cpy ... + $ cpy Options --no-overwrite Don't overwrite the destination @@ -46,8 +46,3 @@ $ cpy --help ## Related - [cpy](https://github.com/sindresorhus/cpy) - API for this module - - -## License - -MIT © [Sindre Sorhus](https://sindresorhus.com) diff --git a/test.js b/test.js index 34cc080..c6220e8 100644 --- a/test.js +++ b/test.js @@ -12,12 +12,12 @@ test.beforeEach(t => { }); test('missing file operands', async t => { - await t.throws(execa('./cli.js'), /`files` and `destination` required/); + await t.throwsAsync(execa('./cli.js'), /`files` and `destination` required/); }); // TODO: Blocked by https://github.com/mrmlnc/fast-glob/issues/110 test.failing('source file does not exist', async t => { - await t.throws(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]), /nonexistentfile/); }); test('cwd', async t => {