copy-folder-util 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/bin/cli.js +14 -20
- package/dist/copy-folder.d.ts +4 -4
- package/dist/copy-folder.js +1 -1
- package/dist/copy-folder.umd.cjs +1 -1
- package/package.json +6 -5
package/README.md
CHANGED
|
@@ -52,6 +52,7 @@ Command-line flags:
|
|
|
52
52
|
| `--basename` | Filter files by filename ignoring the file extension. | **string** |
|
|
53
53
|
| `--cd` | Change working directory before starting copy. | **string** |
|
|
54
54
|
| `--ext` | Filter files by file extension, such as `.js`.<br>Use a comma to specify multiple extensions. | **string** |
|
|
55
|
+
| `--note` | Place to add a comment only for humans. | **string** |
|
|
55
56
|
| `--quiet` | Suppress informational messages. | N/A |
|
|
56
57
|
| `--summary` | Only print out the single line summary message. | N/A |
|
|
57
58
|
|
package/bin/cli.js
CHANGED
|
@@ -21,22 +21,16 @@
|
|
|
21
21
|
// $ node bin/cli.js --cd=spec/fixtures source --ext=.js target/ext-js
|
|
22
22
|
|
|
23
23
|
// Imports
|
|
24
|
+
import { cliArgvUtil } from 'cli-argv-util';
|
|
24
25
|
import { copyFolder } from '../dist/copy-folder.js';
|
|
25
26
|
import chalk from 'chalk';
|
|
26
27
|
import log from 'fancy-log';
|
|
27
28
|
|
|
28
|
-
// Parameters
|
|
29
|
-
const validFlags =
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const flagOn = Object.fromEntries(validFlags.map(flag => [flag, flag in flagMap]));
|
|
34
|
-
const invalidFlag = Object.keys(flagMap).find(key => !validFlags.includes(key));
|
|
35
|
-
const params = args.filter(arg => !/^--/.test(arg));
|
|
36
|
-
|
|
37
|
-
// Data
|
|
38
|
-
const source = params[0];
|
|
39
|
-
const target = params[1];
|
|
29
|
+
// Parameters and flags
|
|
30
|
+
const validFlags = ['cd', 'ext', 'note', 'quiet', 'summary'];
|
|
31
|
+
const cli = cliArgvUtil.parse(validFlags);
|
|
32
|
+
const source = cli.params[0];
|
|
33
|
+
const target = cli.params[1];
|
|
40
34
|
|
|
41
35
|
// Reporting
|
|
42
36
|
const printReport = (results) => {
|
|
@@ -48,23 +42,23 @@ const printReport = (results) => {
|
|
|
48
42
|
const info = infoColor(`(files: ${results.count}, ${results.duration}ms)`);
|
|
49
43
|
const logFile = (file) => log(name, chalk.white(file.origin), arrow.little, chalk.green(file.dest));
|
|
50
44
|
log(name, source, arrow.big, target, info);
|
|
51
|
-
if (!flagOn.summary)
|
|
45
|
+
if (!cli.flagOn.summary)
|
|
52
46
|
results.files.forEach(logFile);
|
|
53
47
|
};
|
|
54
48
|
|
|
55
49
|
// Copy Folder
|
|
56
50
|
const error =
|
|
57
|
-
invalidFlag ?
|
|
58
|
-
!source ?
|
|
59
|
-
!target ?
|
|
60
|
-
|
|
51
|
+
cli.invalidFlag ? cli.invalidFlagMsg :
|
|
52
|
+
!source ? 'Missing source folder.' :
|
|
53
|
+
!target ? 'Missing target folder.' :
|
|
54
|
+
cli.paramsCount > 2 ? 'Extraneous parameter: ' + cli.params[2] :
|
|
61
55
|
null;
|
|
62
56
|
if (error)
|
|
63
57
|
throw Error('[copy-folder-util] ' + error);
|
|
64
58
|
const options = {
|
|
65
|
-
cd: flagMap.cd ?? null,
|
|
66
|
-
fileExtensions: flagMap.ext?.split(',') ?? [],
|
|
59
|
+
cd: cli.flagMap.cd ?? null,
|
|
60
|
+
fileExtensions: cli.flagMap.ext?.split(',') ?? [],
|
|
67
61
|
};
|
|
68
62
|
const results = copyFolder.cp(source, target, options);
|
|
69
|
-
if (!flagOn.quiet)
|
|
63
|
+
if (!cli.flagOn.quiet)
|
|
70
64
|
printReport(results);
|
package/dist/copy-folder.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
//! copy-folder-util v0.2.
|
|
1
|
+
//! copy-folder-util v0.2.3 ~~ https://github.com/center-key/copy-folder-util ~~ MIT License
|
|
2
2
|
|
|
3
|
-
export
|
|
3
|
+
export type Settings = {
|
|
4
4
|
basename: string;
|
|
5
5
|
cd: string;
|
|
6
6
|
fileExtensions: string[];
|
|
7
7
|
};
|
|
8
|
-
export
|
|
9
|
-
export
|
|
8
|
+
export type Options = Partial<Settings>;
|
|
9
|
+
export type Results = {
|
|
10
10
|
source: string;
|
|
11
11
|
target: string;
|
|
12
12
|
count: number;
|
package/dist/copy-folder.js
CHANGED
package/dist/copy-folder.umd.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//! copy-folder-util v0.2.
|
|
1
|
+
//! copy-folder-util v0.2.3 ~~ https://github.com/center-key/copy-folder-util ~~ MIT License
|
|
2
2
|
|
|
3
3
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
4
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "copy-folder-util",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Recursively copy files from one folder to another folder (CLI tool designed for use in npm scripts)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -83,23 +83,24 @@
|
|
|
83
83
|
},
|
|
84
84
|
"dependencies": {
|
|
85
85
|
"chalk": "~5.1",
|
|
86
|
+
"cli-argv-util": "~0.1",
|
|
86
87
|
"fancy-log": "~2.0",
|
|
87
88
|
"slash": "~5.0"
|
|
88
89
|
},
|
|
89
90
|
"devDependencies": {
|
|
90
91
|
"@types/fancy-log": "~2.0",
|
|
91
92
|
"@types/node": "~18.11",
|
|
92
|
-
"@typescript-eslint/eslint-plugin": "~5.
|
|
93
|
-
"@typescript-eslint/parser": "~5.
|
|
93
|
+
"@typescript-eslint/eslint-plugin": "~5.43",
|
|
94
|
+
"@typescript-eslint/parser": "~5.43",
|
|
94
95
|
"add-dist-header": "~0.3",
|
|
95
96
|
"assert-deep-strict-equal": "~1.0",
|
|
96
97
|
"copy-file-util": "~0.1",
|
|
97
|
-
"eslint": "~8.
|
|
98
|
+
"eslint": "~8.27",
|
|
98
99
|
"jshint": "~2.13",
|
|
99
100
|
"mocha": "~10.1",
|
|
100
101
|
"rev-web-assets": "~0.1",
|
|
101
102
|
"rimraf": "~3.0",
|
|
102
103
|
"run-scripts-util": "~0.1",
|
|
103
|
-
"typescript": "~4.
|
|
104
|
+
"typescript": "~4.9"
|
|
104
105
|
}
|
|
105
106
|
}
|