copy-folder-util 1.2.2 → 1.2.4

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-2025 Individual contributors to copy-folder-util
3
+ Copyright (c) 2022-2026 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
@@ -94,17 +94,16 @@ See the **TypeScript Declarations** at the top of [copy-folder.ts](src/copy-fold
94
94
  <br>
95
95
 
96
96
  ---
97
- **CLI Build Tools for package.json**
98
- - 🎋 [add-dist-header](https://github.com/center-key/add-dist-header):&nbsp; _Prepend a one-line banner comment (with license notice) to distribution files_
99
- - 📄 [copy-file-util](https://github.com/center-key/copy-file-util):&nbsp; _Copy or rename a file with optional package version number_
100
- - 📂 [copy-folder-util](https://github.com/center-key/copy-folder-util):&nbsp; _Recursively copy files from one folder to another folder_
101
- - 🪺 [recursive-exec](https://github.com/center-key/recursive-exec):&nbsp; _Run a command on each file in a folder and its subfolders_
102
- - 🔍 [replacer-util](https://github.com/center-key/replacer-util):&nbsp; _Find and replace strings or template outputs in text files_
103
- - 🔢 [rev-web-assets](https://github.com/center-key/rev-web-assets):&nbsp; _Revision web asset filenames with cache busting content hash fingerprints_
104
- - 🚆 [run-scripts-util](https://github.com/center-key/run-scripts-util):&nbsp; _Organize npm package.json scripts into groups of easy to manage commands_
105
- - 🚦 [w3c-html-validator](https://github.com/center-key/w3c-html-validator):&nbsp; _Check the markup validity of HTML files using the W3C validator_
106
-
107
- Feel free to submit questions at:<br>
108
- [github.com/center-key/copy-folder-util/issues](https://github.com/center-key/copy-folder-util/issues)
109
-
110
97
  [MIT License](LICENSE.txt)
98
+
99
+ [🛡️ npm Security Aggregator](https://center-key.github.io/npm-security-aggregator/?package=copy-folder-util)
100
+
101
+ See the `runScriptsConfig` section of [`package.json`](package.json) for a clean way to organize build tasks:
102
+ - 🎋 [`add-dist-header`](https://github.com/center-key/add-dist-header) &mdash;&nbsp; _Prepend a one-line banner comment (with license notice) to distribution files_
103
+ - 📄 [`copy-file-util`](https://github.com/center-key/copy-file-util) &mdash;&nbsp; _Copy or rename a file with optional package version number_
104
+ - 📂 [`copy-folder-util`](https://github.com/center-key/copy-folder-util) &mdash;&nbsp; _Recursively copy files from one folder to another folder_
105
+ - 🪺 [`recursive-exec`](https://github.com/center-key/recursive-exec) &mdash;&nbsp; _Run a command on each file in a folder and its subfolders_
106
+ - 🔍 [`replacer-util`](https://github.com/center-key/replacer-util) &mdash;&nbsp; _Find and replace strings or template outputs in text files_
107
+ - 🔢 [`rev-web-assets`](https://github.com/center-key/rev-web-assets) &mdash;&nbsp; _Revision web asset filenames with cache busting content hash fingerprints_
108
+ - 🚆 [`run-scripts-util`](https://github.com/center-key/run-scripts-util) &mdash;&nbsp; _Organize npm package.json scripts into groups of easy-to-manage commands_
109
+ - 🚦 [`w3c-html-validator`](https://github.com/center-key/w3c-html-validator) &mdash;&nbsp; _Check the markup validity of HTML files using the W3C validator_
@@ -1,4 +1,4 @@
1
- //! copy-folder-util v1.2.2 ~~ https://github.com/center-key/copy-folder-util ~~ MIT License
1
+ //! copy-folder-util v1.2.4 ~~ https://github.com/center-key/copy-folder-util ~~ MIT License
2
2
 
3
3
  export type Settings = {
4
4
  basename: string | null;
@@ -11,6 +11,7 @@ export type Results = {
11
11
  count: number;
12
12
  duration: number;
13
13
  files: {
14
+ filename: string;
14
15
  origin: string;
15
16
  dest: string;
16
17
  }[];
@@ -1,10 +1,10 @@
1
- //! copy-folder-util v1.2.2 ~~ https://github.com/center-key/copy-folder-util ~~ MIT License
1
+ //! copy-folder-util v1.2.4 ~~ https://github.com/center-key/copy-folder-util ~~ MIT License
2
2
 
3
3
  import { cliArgvUtil } from 'cli-argv-util';
4
4
  import chalk from 'chalk';
5
- import fs from 'fs';
5
+ import fs from 'node:fs';
6
6
  import log from 'fancy-log';
7
- import path from 'path';
7
+ import path from 'node:path';
8
8
  import slash from 'slash';
9
9
  const copyFolder = {
10
10
  extraneous: {
@@ -63,11 +63,11 @@ const copyFolder = {
63
63
  };
64
64
  const files = [];
65
65
  const posixPath = (nativePath) => slash(nativePath.replace(/.*:/, ''));
66
- const relativePath = (fullPath, start) => fullPath.substring(fullPath.indexOf(start) + start.length + 1);
67
66
  const filter = (origin, dest) => {
68
67
  const isFile = fs.statSync(origin).isFile();
69
68
  const name = path.basename(origin);
70
69
  const ext = path.extname(origin);
70
+ const ancestor = cliArgvUtil.calcAncestor(posixPath(origin), posixPath(dest));
71
71
  const keepFolder = !isFile && !copyFolder.extraneous.folders.includes(name);
72
72
  const keepFile = isFile &&
73
73
  (filterOff.base || name.replace(/[.].*/, '') === settings.basename) &&
@@ -75,8 +75,9 @@ const copyFolder = {
75
75
  !copyFolder.extraneous.files.includes(name);
76
76
  if (keepFile)
77
77
  files.push({
78
- origin: relativePath(posixPath(origin), source),
79
- dest: relativePath(posixPath(dest), target),
78
+ filename: name,
79
+ origin: path.dirname(ancestor.source) + '/',
80
+ dest: path.dirname(ancestor.target) + '/',
80
81
  });
81
82
  return keepFolder || keepFile;
82
83
  };
@@ -99,7 +100,8 @@ const copyFolder = {
99
100
  const infoColor = results.count ? chalk.white : chalk.red.bold;
100
101
  const info = infoColor(`(files: ${results.count}, ${results.duration}ms)`);
101
102
  log(name, ancestor.message, info);
102
- const logFile = (file, i) => log(name, chalk.magenta(i + 1), cliArgvUtil.calcAncestor(file.origin, file.dest).message);
103
+ const message = (source, filename, target) => chalk.gray(source) + cliArgvUtil.calcAncestor(filename, target).message;
104
+ const logFile = (file, i) => log(name, chalk.magenta(i + 1), message(file.origin, file.filename, file.dest));
103
105
  if (!settings.summaryOnly)
104
106
  results.files.forEach(logFile);
105
107
  return results;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "copy-folder-util",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "description": "Recursively copy files from one folder to another folder (CLI tool designed for use in npm package.json scripts)",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -63,24 +63,24 @@
63
63
  },
64
64
  "dependencies": {
65
65
  "chalk": "~5.6",
66
- "cli-argv-util": "~1.4",
66
+ "cli-argv-util": "~1.5",
67
67
  "fancy-log": "~2.0",
68
68
  "slash": "~5.1"
69
69
  },
70
70
  "devDependencies": {
71
- "@eslint/js": "~9.39",
71
+ "@eslint/js": "~10.0",
72
72
  "@types/fancy-log": "~2.0",
73
- "@types/node": "~25.0",
73
+ "@types/node": "~25.9",
74
74
  "add-dist-header": "~1.6",
75
75
  "assert-deep-strict-equal": "~1.2",
76
76
  "copy-file-util": "~1.3",
77
- "eslint": "~9.39",
77
+ "eslint": "~10.4",
78
78
  "jshint": "~2.13",
79
79
  "mocha": "~11.7",
80
80
  "rimraf": "~6.1",
81
81
  "run-scripts-util": "~1.3",
82
- "typescript": "~5.9",
83
- "typescript-eslint": "~8.50",
84
- "w3c-html-validator": "~2.0"
82
+ "typescript": "~6.0",
83
+ "typescript-eslint": "~8.60",
84
+ "w3c-html-validator": "~2.2"
85
85
  }
86
86
  }