copy-folder-util 1.1.1 → 1.1.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/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2022-2023 Individual contributors to copy-folder-util
3
+ Copyright (c) 2022-2024 Individual contributors to copy-folder-util
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -56,19 +56,24 @@ Command-line flags:
56
56
 
57
57
  Examples:
58
58
  - `copy-folder build --basename=index dist` <br>
59
- Only copy files with filenames matching `index.*`.
59
+ Only copies files with filenames matching `index.*`.
60
60
 
61
61
  - `copy-folder -cd=spec fixtures mock1`<br>
62
- Copy the folder **spec/fixtures** to **spec/mock1**.
62
+ Copies the folder **spec/fixtures** to **spec/mock1**.
63
63
 
64
64
  - `copy-folder build dist --summary`<br>
65
65
  Displays the summary but not the individual files copied.
66
66
 
67
+ - `copy-folder 'src/Legal Notices' dist --summary`<br>
68
+ Copies a folder that has a space in its name.
69
+
67
70
  - `copy-folder src/web --ext=.js,.html docs`<br>
68
- Copy only the JavaScript and HTML files to the **docs** folder.
71
+ Copies only the JavaScript and HTML files to the **docs** folder.
72
+
73
+ _**Note:** Single quotes in commands are normalized so they work cross-platform and avoid the errors often encountered on Microsoft Windows._
69
74
 
70
75
  ## C) Application Code
71
- Even though **copy-folder-util** is primarily intended for build scripts, the package can easily be used programmatically in ESM and TypeScript projects.
76
+ Even though **copy-folder-util** is primarily intended for build scripts, the package can be used programmatically in ESM and TypeScript projects.
72
77
 
73
78
  Example:
74
79
  ``` typescript
@@ -84,7 +89,7 @@ See the **TypeScript Declarations** at the top of [copy-folder.ts](copy-folder.t
84
89
  <br>
85
90
 
86
91
  ---
87
- **CLI Build Tools**
92
+ **CLI Build Tools for package.json**
88
93
  - 🎋 [add-dist-header](https://github.com/center-key/add-dist-header):&nbsp; _Prepend a one-line banner comment (with license notice) to distribution files_
89
94
  - 📄 [copy-file-util](https://github.com/center-key/copy-file-util):&nbsp; _Copy or rename a file with optional package version number_
90
95
  - 📂 [copy-folder-util](https://github.com/center-key/copy-folder-util):&nbsp; _Recursively copy files from one folder to another folder_
package/bin/cli.js CHANGED
@@ -23,8 +23,6 @@
23
23
  // Imports
24
24
  import { cliArgvUtil } from 'cli-argv-util';
25
25
  import { copyFolder } from '../dist/copy-folder.js';
26
- import chalk from 'chalk';
27
- import log from 'fancy-log';
28
26
 
29
27
  // Parameters and flags
30
28
  const validFlags = ['cd', 'ext', 'note', 'quiet', 'summary'];
@@ -32,20 +30,6 @@ const cli = cliArgvUtil.parse(validFlags);
32
30
  const source = cli.params[0];
33
31
  const target = cli.params[1];
34
32
 
35
- // Reporting
36
- const printReport = (results) => {
37
- const name = chalk.gray('copy-folder');
38
- const source = chalk.blue.bold(results.source);
39
- const target = chalk.magenta(results.target);
40
- const arrow = { big: chalk.gray.bold(' ⟹ '), little: chalk.gray.bold('→') };
41
- const infoColor = results.count ? chalk.white : chalk.red.bold;
42
- const info = infoColor(`(files: ${results.count}, ${results.duration}ms)`);
43
- const logFile = (file) => log(name, chalk.white(file.origin), arrow.little, chalk.green(file.dest));
44
- log(name, source, arrow.big, target, info);
45
- if (!cli.flagOn.summary)
46
- results.files.forEach(logFile);
47
- };
48
-
49
33
  // Copy Folder
50
34
  const error =
51
35
  cli.invalidFlag ? cli.invalidFlagMsg :
@@ -61,4 +45,4 @@ const options = {
61
45
  };
62
46
  const results = copyFolder.cp(source, target, options);
63
47
  if (!cli.flagOn.quiet)
64
- printReport(results);
48
+ copyFolder.reporter(results, { summaryOnly: cli.flagOn.summary });
@@ -1,11 +1,10 @@
1
- //! copy-folder-util v1.1.1 ~~ https://github.com/center-key/copy-folder-util ~~ MIT License
1
+ //! copy-folder-util v1.1.3 ~~ https://github.com/center-key/copy-folder-util ~~ MIT License
2
2
 
3
3
  export type Settings = {
4
4
  basename: string;
5
5
  cd: string;
6
6
  fileExtensions: string[];
7
7
  };
8
- export type Options = Partial<Settings>;
9
8
  export type Results = {
10
9
  source: string;
11
10
  target: string;
@@ -16,7 +15,11 @@ export type Results = {
16
15
  dest: string;
17
16
  }[];
18
17
  };
18
+ export type ReporterSettings = {
19
+ summaryOnly: boolean;
20
+ };
19
21
  declare const copyFolder: {
20
- cp(sourceFolder: string, targetFolder: string, options?: Options): Results;
22
+ cp(sourceFolder: string, targetFolder: string, options?: Partial<Settings>): Results;
23
+ reporter(results: Results, options?: Partial<ReporterSettings>): Results;
21
24
  };
22
25
  export { copyFolder };
@@ -1,6 +1,8 @@
1
- //! copy-folder-util v1.1.1 ~~ https://github.com/center-key/copy-folder-util ~~ MIT License
1
+ //! copy-folder-util v1.1.3 ~~ https://github.com/center-key/copy-folder-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 extraneousFiles = ['.DS_Store', 'Thumbs.db', 'desktop.ini'];
@@ -61,5 +63,22 @@ const copyFolder = {
61
63
  files: files,
62
64
  };
63
65
  },
66
+ reporter(results, options) {
67
+ const defaults = {
68
+ summaryOnly: false,
69
+ };
70
+ const settings = { ...defaults, ...options };
71
+ const name = chalk.gray('copy-folder');
72
+ const source = chalk.blue.bold(results.source);
73
+ const target = chalk.magenta(results.target);
74
+ const arrow = { big: chalk.gray.bold(' ⟹ '), little: chalk.gray.bold('→') };
75
+ const infoColor = results.count ? chalk.white : chalk.red.bold;
76
+ const info = infoColor(`(files: ${results.count}, ${results.duration}ms)`);
77
+ log(name, source, arrow.big, target, info);
78
+ const logFile = (file) => log(name, chalk.white(file.origin), arrow.little, chalk.green(file.dest));
79
+ if (!settings.summaryOnly)
80
+ results.files.forEach(logFile);
81
+ return results;
82
+ },
64
83
  };
65
84
  export { copyFolder };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "copy-folder-util",
3
- "version": "1.1.1",
3
+ "version": "1.1.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",
@@ -20,7 +20,10 @@
20
20
  "copy-folder": "bin/cli.js",
21
21
  "copy-folder-util": "bin/cli.js"
22
22
  },
23
- "repository": "github:center-key/copy-folder-util",
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/center-key/copy-folder-util.git"
26
+ },
24
27
  "homepage": "https://github.com/center-key/copy-folder-util",
25
28
  "bugs": "https://github.com/center-key/copy-folder-util/issues",
26
29
  "docs": "https://github.com/center-key/copy-folder-util#readme",
@@ -90,17 +93,17 @@
90
93
  },
91
94
  "devDependencies": {
92
95
  "@types/fancy-log": "~2.0",
93
- "@types/node": "~20.5",
94
- "@typescript-eslint/eslint-plugin": "~6.4",
95
- "@typescript-eslint/parser": "~6.4",
96
- "add-dist-header": "~1.2",
96
+ "@types/node": "~20.10",
97
+ "@typescript-eslint/eslint-plugin": "~6.17",
98
+ "@typescript-eslint/parser": "~6.17",
99
+ "add-dist-header": "~1.3",
97
100
  "assert-deep-strict-equal": "~1.1",
98
101
  "copy-file-util": "~1.1",
99
- "eslint": "~8.47",
102
+ "eslint": "~8.56",
100
103
  "jshint": "~2.13",
101
104
  "mocha": "~10.2",
102
105
  "rimraf": "~5.0",
103
106
  "run-scripts-util": "~1.2",
104
- "typescript": "~5.1"
107
+ "typescript": "~5.3"
105
108
  }
106
109
  }