copy-file-util 1.1.1 → 1.1.2
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 +2 -2
- package/bin/cli.js +2 -14
- package/dist/copy-file.d.ts +4 -3
- package/dist/copy-file.js +12 -1
- package/package.json +11 -8
package/README.md
CHANGED
|
@@ -71,7 +71,7 @@ Example:
|
|
|
71
71
|
Creates a copy of **app.js** named something like **app-v1.2.3.js** based on the version of your project.
|
|
72
72
|
|
|
73
73
|
## C) Application Code
|
|
74
|
-
Even though **copy-file-util** is primarily intended for build scripts, the package can
|
|
74
|
+
Even though **copy-file-util** is primarily intended for build scripts, the package can be used programmatically in ESM and TypeScript projects.
|
|
75
75
|
|
|
76
76
|
Example:
|
|
77
77
|
``` typescript
|
|
@@ -86,7 +86,7 @@ See the **TypeScript Declarations** at the top of [copy-file.ts](copy-file.ts) f
|
|
|
86
86
|
<br>
|
|
87
87
|
|
|
88
88
|
---
|
|
89
|
-
**CLI Build Tools**
|
|
89
|
+
**CLI Build Tools for package.json**
|
|
90
90
|
- 🎋 [add-dist-header](https://github.com/center-key/add-dist-header): _Prepend a one-line banner comment (with license notice) to distribution files_
|
|
91
91
|
- 📄 [copy-file-util](https://github.com/center-key/copy-file-util): _Copy or rename a file with optional package version number_
|
|
92
92
|
- 📂 [copy-folder-util](https://github.com/center-key/copy-folder-util): _Recursively copy files from one folder to another folder_
|
package/bin/cli.js
CHANGED
|
@@ -24,9 +24,7 @@
|
|
|
24
24
|
import { cliArgvUtil } from 'cli-argv-util';
|
|
25
25
|
import { copyFile } from '../dist/copy-file.js';
|
|
26
26
|
import { dna } from 'dna-engine';
|
|
27
|
-
import
|
|
28
|
-
import fs from 'fs';
|
|
29
|
-
import log from 'fancy-log';
|
|
27
|
+
import fs from 'fs';
|
|
30
28
|
|
|
31
29
|
// Parameters and flags
|
|
32
30
|
const validFlags = ['cd', 'folder', 'move', 'note', 'quiet'];
|
|
@@ -39,16 +37,6 @@ const readPackage = () => JSON.parse(fs.readFileSync('package.json', 'utf-8'));
|
|
|
39
37
|
const getPackageField = (match) =>
|
|
40
38
|
dna.util.value({ pkg: readPackage() }, match.replace(/[{}]/g, '')) ?? 'MISSING-FIELD-ERROR';
|
|
41
39
|
|
|
42
|
-
// Reporting
|
|
43
|
-
const printReport = (result) => {
|
|
44
|
-
const name = chalk.gray('copy-file');
|
|
45
|
-
const origin = chalk.blue.bold(result.origin);
|
|
46
|
-
const dest = chalk.magenta(result.dest);
|
|
47
|
-
const arrow = chalk.gray.bold('→');
|
|
48
|
-
const info = chalk.white(`(${result.duration}ms${result.moved ? ', move' : ''})`);
|
|
49
|
-
log(name, origin, arrow, dest, info);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
40
|
// Copy File
|
|
53
41
|
const error =
|
|
54
42
|
cli.invalidFlag ? cli.invalidFlagMsg :
|
|
@@ -67,4 +55,4 @@ const options = {
|
|
|
67
55
|
};
|
|
68
56
|
const result = copyFile.cp(source, options);
|
|
69
57
|
if (!cli.flagOn.quiet)
|
|
70
|
-
|
|
58
|
+
copyFile.reporter(result);
|
package/dist/copy-file.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
//! copy-file-util v1.1.
|
|
1
|
+
//! copy-file-util v1.1.2 ~~ https://github.com/center-key/copy-file-util ~~ MIT License
|
|
2
2
|
|
|
3
|
-
export type
|
|
3
|
+
export type Settings = {
|
|
4
4
|
cd: string;
|
|
5
5
|
targetFile: string;
|
|
6
6
|
targetFolder: string;
|
|
@@ -14,6 +14,7 @@ export type Result = {
|
|
|
14
14
|
moved: boolean;
|
|
15
15
|
};
|
|
16
16
|
declare const copyFile: {
|
|
17
|
-
cp(sourceFile: string, options
|
|
17
|
+
cp(sourceFile: string, options?: Partial<Settings>): Result;
|
|
18
|
+
reporter(result: Result): Result;
|
|
18
19
|
};
|
|
19
20
|
export { copyFile };
|
package/dist/copy-file.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
//! copy-file-util v1.1.
|
|
1
|
+
//! copy-file-util v1.1.2 ~~ https://github.com/center-key/copy-file-util ~~ MIT License
|
|
2
2
|
|
|
3
|
+
import chalk from 'chalk';
|
|
3
4
|
import fs from 'fs';
|
|
5
|
+
import log from 'fancy-log';
|
|
4
6
|
import path from 'path';
|
|
5
7
|
import slash from 'slash';
|
|
6
8
|
const copyFile = {
|
|
@@ -50,5 +52,14 @@ const copyFile = {
|
|
|
50
52
|
duration: Date.now() - startTime,
|
|
51
53
|
};
|
|
52
54
|
},
|
|
55
|
+
reporter(result) {
|
|
56
|
+
const name = chalk.gray('copy-file');
|
|
57
|
+
const origin = chalk.blue.bold(result.origin);
|
|
58
|
+
const dest = chalk.magenta(result.dest);
|
|
59
|
+
const arrow = chalk.gray.bold('→');
|
|
60
|
+
const info = chalk.white(`(${result.duration}ms${result.moved ? ', move' : ''})`);
|
|
61
|
+
log(name, origin, arrow, dest, info);
|
|
62
|
+
return result;
|
|
63
|
+
},
|
|
53
64
|
};
|
|
54
65
|
export { copyFile };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "copy-file-util",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Copy or rename a file with optional package version number (CLI tool designed for use in npm scripts)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -20,7 +20,10 @@
|
|
|
20
20
|
"copy-file": "bin/cli.js",
|
|
21
21
|
"copy-file-util": "bin/cli.js"
|
|
22
22
|
},
|
|
23
|
-
"repository":
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://github.com/center-key/copy-file-util.git"
|
|
26
|
+
},
|
|
24
27
|
"homepage": "https://github.com/center-key/copy-file-util",
|
|
25
28
|
"bugs": "https://github.com/center-key/copy-file-util/issues",
|
|
26
29
|
"docs": "https://github.com/center-key/copy-file-util#readme",
|
|
@@ -88,16 +91,16 @@
|
|
|
88
91
|
},
|
|
89
92
|
"devDependencies": {
|
|
90
93
|
"@types/fancy-log": "~2.0",
|
|
91
|
-
"@types/node": "~20.
|
|
92
|
-
"@typescript-eslint/eslint-plugin": "~6.
|
|
93
|
-
"@typescript-eslint/parser": "~6.
|
|
94
|
-
"add-dist-header": "~1.
|
|
94
|
+
"@types/node": "~20.6",
|
|
95
|
+
"@typescript-eslint/eslint-plugin": "~6.7",
|
|
96
|
+
"@typescript-eslint/parser": "~6.7",
|
|
97
|
+
"add-dist-header": "~1.3",
|
|
95
98
|
"assert-deep-strict-equal": "~1.1",
|
|
96
|
-
"eslint": "~8.
|
|
99
|
+
"eslint": "~8.50",
|
|
97
100
|
"jshint": "~2.13",
|
|
98
101
|
"mocha": "~10.2",
|
|
99
102
|
"rimraf": "~5.0",
|
|
100
103
|
"run-scripts-util": "~1.2",
|
|
101
|
-
"typescript": "~5.
|
|
104
|
+
"typescript": "~5.2"
|
|
102
105
|
}
|
|
103
106
|
}
|