Skip to content

Commit 489b89e

Browse files
authored
fix(deps): update cli-nano to latest w/better typing & smaller build (#29)
* fix(deps): update cli-nano to latest w/better typing & smaller build * chore: fix failing unit test
1 parent 54344fb commit 489b89e

File tree

4 files changed

+21
-11
lines changed

4 files changed

+21
-11
lines changed

package-lock.json

Lines changed: 13 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"test:coverage": "vitest --coverage --config ./vitest.config.mts"
5555
},
5656
"dependencies": {
57-
"cli-nano": "^1.0.2",
57+
"cli-nano": "^1.1.3",
5858
"tinyglobby": "^0.2.14",
5959
"untildify": "^5.0.0"
6060
},

src/__tests__/cli-fail.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe('copyfiles', () => {
2121
// expect(exitSpy).toHaveBeenCalledWith(1);
2222
// Please make sure to provide both <inFile> and <outDirectory>, i.e.: "copyfiles <inFile> <outDirectory>"
2323
expect(errorSpy).toHaveBeenCalledWith(
24-
new Error('Missing required positional argument, i.e.: "copyfiles <inFile> <outDirectory>"'),
24+
new Error('Missing required positional argument, i.e.: "copyfiles <inFile..> <outDirectory>"'),
2525
);
2626
expect(exitSpy).toHaveBeenCalledWith(1);
2727
process.exitCode = undefined;

src/cli.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { fileURLToPath } from 'node:url';
66
import { parseArgs } from 'cli-nano';
77

88
import { copyfiles } from './index.js';
9-
import type { CopyFileOptions } from './interfaces.js';
109

1110
function readPackage() {
1211
const __dirname = dirname(fileURLToPath(import.meta.url));
@@ -25,7 +24,7 @@ function handleError(err?: Error) {
2524
}
2625

2726
try {
28-
const results = parseArgs({
27+
const config = {
2928
command: {
3029
name: 'copyfiles',
3130
description: 'Copy files from a source to a destination directory',
@@ -41,6 +40,7 @@ try {
4140
name: 'outDirectory',
4241
description: 'Destination directory',
4342
required: true,
43+
type: 'string',
4444
},
4545
],
4646
},
@@ -92,8 +92,10 @@ try {
9292
},
9393
},
9494
version: readPackage().version,
95-
});
96-
copyfiles([...results.inFile, results.outDirectory], results as CopyFileOptions, err => handleError(err));
95+
} as const;
96+
97+
const results = parseArgs(config);
98+
copyfiles([...results.inFile, results.outDirectory], results, err => handleError(err));
9799
} catch (err) {
98100
handleError(err as Error);
99101
}

0 commit comments

Comments
 (0)