copy-folder-util 0.2.0 → 0.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  # copy-folder-util
2
2
  <img src=https://centerkey.com/graphics/center-key-logo.svg align=right width=200 alt=logo>
3
3
 
4
- _Recursively copy a folder (CLI tool designed for use in npm scripts)_
4
+ _Recursively copy files from one folder to another folder (CLI tool designed for use in npm scripts)_
5
5
 
6
6
  [![License:MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/center-key/copy-folder-util/blob/main/LICENSE.txt)
7
7
  [![npm](https://img.shields.io/npm/v/copy-folder-util.svg)](https://www.npmjs.com/package/copy-folder-util)
@@ -35,7 +35,6 @@ Example **package.json** scripts:
35
35
  "make-docs": "copy-folder src/web --ext=.html docs/api-manual"
36
36
  },
37
37
  ```
38
- Try out the first script with the command: `npm run make-dist`
39
38
 
40
39
  ### 2. Global
41
40
  You can install **copy-folder-util** globally and then run it anywhere directly from the terminal.
@@ -80,10 +79,11 @@ See the **TypeScript Declarations** at the top of [copy-folder.ts](copy-folder.t
80
79
  ---
81
80
  **CLI Build Tools**
82
81
  - 🎋 [add-dist-header](https://github.com/center-key/add-dist-header):&nbsp; _Prepend a one-line banner comment (with license notice) to distribution files_
83
- - 📄 [copy-file-util](https://github.com/center-key/copy-file-util):&nbsp; _Copy or rename a file_
84
- - 📂 [copy-folder-util](https://github.com/center-key/copy-folder-util):&nbsp; _Recursively copy the files in a folder_
82
+ - 📄 [copy-file-util](https://github.com/center-key/copy-file-util):&nbsp; _Copy or rename a file with optional package version number_
83
+ - 📂 [copy-folder-util](https://github.com/center-key/copy-folder-util):&nbsp; _Recursively copy files from one folder to another folder_
85
84
  - 🔍 [replacer-util](https://github.com/center-key/replacer-util):&nbsp; _Find and replace strings or template outputs in text files_
86
85
  - 🔢 [rev-web-assets](https://github.com/center-key/rev-web-assets):&nbsp; _Revision web asset filenames with cache busting content hash fingerprints_
86
+ - 🚆 [run-scripts-util](https://github.com/center-key/run-scripts-util):&nbsp; _Organize npm scripts into named groups of easy to manage commands_
87
87
  - 🚦 [w3c-html-validator](https://github.com/center-key/w3c-html-validator):&nbsp; _Check the markup validity of HTML files using the W3C validator_
88
88
 
89
89
  Feel free to submit questions at:<br>
@@ -1,4 +1,4 @@
1
- //! copy-folder-util v0.2.0 ~~ https://github.com/center-key/copy-folder-util ~~ MIT License
1
+ //! copy-folder-util v0.2.1 ~~ https://github.com/center-key/copy-folder-util ~~ MIT License
2
2
 
3
3
  export declare type Settings = {
4
4
  basename: string;
@@ -1,4 +1,4 @@
1
- //! copy-folder-util v0.2.0 ~~ https://github.com/center-key/copy-folder-util ~~ MIT License
1
+ //! copy-folder-util v0.2.1 ~~ https://github.com/center-key/copy-folder-util ~~ MIT License
2
2
 
3
3
  import fs from 'fs';
4
4
  import path from 'path';
@@ -34,6 +34,8 @@ const copyFolder = {
34
34
  ext: !settings.fileExtensions || settings.fileExtensions.length === 0,
35
35
  };
36
36
  const files = [];
37
+ const posixPath = (nativePath) => slash(nativePath.replace(/.*:/, ''));
38
+ const relativePath = (fullPath, start) => fullPath.substring(fullPath.indexOf(start) + start.length + 1);
37
39
  const filter = (origin, dest) => {
38
40
  const isFile = fs.statSync(origin).isFile();
39
41
  const name = path.basename(origin);
@@ -45,8 +47,8 @@ const copyFolder = {
45
47
  !extraneousFiles.includes(name);
46
48
  if (keepFile)
47
49
  files.push({
48
- origin: origin.substring(source.length + 1),
49
- dest: dest.substring(target.length + 1),
50
+ origin: relativePath(posixPath(origin), source),
51
+ dest: relativePath(posixPath(dest), target),
50
52
  });
51
53
  return keepFolder || keepFile;
52
54
  };
@@ -1,4 +1,4 @@
1
- //! copy-folder-util v0.2.0 ~~ https://github.com/center-key/copy-folder-util ~~ MIT License
1
+ //! copy-folder-util v0.2.1 ~~ 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 };
@@ -49,6 +49,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
49
49
  ext: !settings.fileExtensions || settings.fileExtensions.length === 0,
50
50
  };
51
51
  const files = [];
52
+ const posixPath = (nativePath) => (0, slash_1.default)(nativePath.replace(/.*:/, ''));
53
+ const relativePath = (fullPath, start) => fullPath.substring(fullPath.indexOf(start) + start.length + 1);
52
54
  const filter = (origin, dest) => {
53
55
  const isFile = fs_1.default.statSync(origin).isFile();
54
56
  const name = path_1.default.basename(origin);
@@ -60,8 +62,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
60
62
  !extraneousFiles.includes(name);
61
63
  if (keepFile)
62
64
  files.push({
63
- origin: origin.substring(source.length + 1),
64
- dest: dest.substring(target.length + 1),
65
+ origin: relativePath(posixPath(origin), source),
66
+ dest: relativePath(posixPath(dest), target),
65
67
  });
66
68
  return keepFolder || keepFile;
67
69
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "copy-folder-util",
3
- "version": "0.2.0",
4
- "description": "Recursively copy a folder (CLI tool designed for use in npm scripts)",
3
+ "version": "0.2.1",
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",
7
7
  "module": "dist/copy-folder.js",
@@ -66,15 +66,19 @@
66
66
  "@typescript-eslint/no-non-null-assertion": "off"
67
67
  }
68
68
  },
69
+ "runScriptsConfig": {
70
+ "build": [
71
+ "rimraf build dist spec/fixtures/target **/.DS_Store",
72
+ "jshint . --exclude-path .gitignore",
73
+ "eslint --max-warnings 0 . --ext .ts",
74
+ "tsc",
75
+ "tsc --module UMD --outDir build/umd",
76
+ "copy-file build/umd/copy-folder.js build/copy-folder.umd.cjs",
77
+ "add-dist-header build dist"
78
+ ]
79
+ },
69
80
  "scripts": {
70
- "step:01": "rimraf build dist spec/fixtures/target **/.DS_Store",
71
- "step:02": "jshint . --exclude-path .gitignore",
72
- "step:03": "eslint --max-warnings 0 . --ext .ts",
73
- "step:04": "tsc",
74
- "step:05": "tsc --module UMD --outDir build/umd",
75
- "step:06": "copy-file build/umd/copy-folder.js build/copy-folder.umd.cjs",
76
- "step:07": "add-dist-header build dist",
77
- "pretest": "npm-run-all step:*",
81
+ "pretest": "run-scripts build",
78
82
  "test": "mocha spec/*.spec.js"
79
83
  },
80
84
  "dependencies": {
@@ -84,18 +88,18 @@
84
88
  },
85
89
  "devDependencies": {
86
90
  "@types/fancy-log": "~2.0",
87
- "@types/node": "~18.8",
91
+ "@types/node": "~18.11",
88
92
  "@typescript-eslint/eslint-plugin": "~5.40",
89
93
  "@typescript-eslint/parser": "~5.40",
90
94
  "add-dist-header": "~0.3",
91
95
  "assert-deep-strict-equal": "~1.0",
92
96
  "copy-file-util": "~0.1",
93
- "eslint": "~8.25",
97
+ "eslint": "~8.26",
94
98
  "jshint": "~2.13",
95
- "mocha": "~10.0",
96
- "npm-run-all2": "~6.0",
99
+ "mocha": "~10.1",
97
100
  "rev-web-assets": "~0.1",
98
101
  "rimraf": "~3.0",
102
+ "run-scripts-util": "~0.1",
99
103
  "typescript": "~4.8"
100
104
  }
101
105
  }