copy-folder-util 1.2.2 → 1.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.
@@ -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.3 ~~ 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,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.3 ~~ 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';
@@ -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.3",
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",