copy-file-util 1.2.1 → 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.
package/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2022-2024 Individual contributors to copy-file-util
3
+ Copyright (c) 2022-2025 Individual contributors to copy-file-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
@@ -90,7 +90,7 @@ const result = copyFile.cp('src/web/api.html' { targetFile: 'docs/api-manual.htm
90
90
  console.log('Execution time:', result.duration, 'ms');
91
91
  ```
92
92
 
93
- See the **TypeScript Declarations** at the top of [copy-file.ts](copy-file.ts) for documentation.
93
+ See the **TypeScript Declarations** at the top of [copy-file.ts](src/copy-file.ts) for documentation.
94
94
 
95
95
  <br>
96
96
 
@@ -102,7 +102,7 @@ See the **TypeScript Declarations** at the top of [copy-file.ts](copy-file.ts) f
102
102
  - 🪺 [recursive-exec](https://github.com/center-key/recursive-exec):&nbsp; _Run a command on each file in a folder and its subfolders_
103
103
  - 🔍 [replacer-util](https://github.com/center-key/replacer-util):&nbsp; _Find and replace strings or template outputs in text files_
104
104
  - 🔢 [rev-web-assets](https://github.com/center-key/rev-web-assets):&nbsp; _Revision web asset filenames with cache busting content hash fingerprints_
105
- - 🚆 [run-scripts-util](https://github.com/center-key/run-scripts-util):&nbsp; _Organize npm package.json scripts into named groups of easy to manage commands_
105
+ - 🚆 [run-scripts-util](https://github.com/center-key/run-scripts-util):&nbsp; _Organize npm package.json scripts into groups of easy to manage commands_
106
106
  - 🚦 [w3c-html-validator](https://github.com/center-key/w3c-html-validator):&nbsp; _Check the markup validity of HTML files using the W3C validator_
107
107
 
108
108
  Feel free to submit questions at:<br>
package/bin/cli.js CHANGED
@@ -30,8 +30,7 @@ import fs from 'fs';
30
30
  const validFlags = ['cd', 'folder', 'move', 'no-overwrite', 'note', 'quiet'];
31
31
  const cli = cliArgvUtil.parse(validFlags);
32
32
  const source = cli.params[0];
33
- //const target = cli.params[1];
34
- const target = cli.params[1].replaceAll('{{pkg.', '{{package.'); //name "pkg" deprecated in favor of "package" for clarity
33
+ const target = cli.params[1];
35
34
 
36
35
  // Utilities
37
36
  const readPackage = () => JSON.parse(fs.readFileSync('package.json', 'utf-8'));
@@ -47,7 +46,7 @@ const error =
47
46
  !target ? 'Missing target file.' :
48
47
  null;
49
48
  if (error)
50
- throw Error('[copy-file-util] ' + error);
49
+ throw new Error('[copy-file-util] ' + error);
51
50
  const targetKey = cli.flagOn.folder ? 'targetFolder' : 'targetFile';
52
51
  const templateVariables = /{{[^{}]*}}/g; //example match: "{{package.version}}"
53
52
  const options = {
@@ -1,4 +1,4 @@
1
- //! copy-file-util v1.2.1 ~~ https://github.com/center-key/copy-file-util ~~ MIT License
1
+ //! copy-file-util v1.2.3 ~~ https://github.com/center-key/copy-file-util ~~ MIT License
2
2
 
3
3
  export type Settings = {
4
4
  cd: string;
package/dist/copy-file.js CHANGED
@@ -1,4 +1,4 @@
1
- //! copy-file-util v1.2.1 ~~ https://github.com/center-key/copy-file-util ~~ MIT License
1
+ //! copy-file-util v1.2.3 ~~ https://github.com/center-key/copy-file-util ~~ MIT License
2
2
 
3
3
  import chalk from 'chalk';
4
4
  import fs from 'fs';
@@ -27,7 +27,7 @@ const copyFile = {
27
27
  const sourceFilename = sourceIsFile ? path.basename(source) : null;
28
28
  const targetPath = settings.targetFile ? path.dirname(settings.targetFile) : settings.targetFolder;
29
29
  const targetFolder = targetPath ? normalize(startFolder + targetPath) : null;
30
- const targetFile = settings.targetFile ?? settings.targetFolder + '/' + sourceFilename;
30
+ const targetFile = settings.targetFile ?? `${settings.targetFolder}/${sourceFilename}`;
31
31
  const target = normalize(startFolder + targetFile);
32
32
  const targetExists = !missingTarget && fs.existsSync(target);
33
33
  const skip = targetExists && !settings.overwrite;
@@ -40,10 +40,10 @@ const copyFile = {
40
40
  !sourceIsFile ? 'Source is not a file: ' + source :
41
41
  missingTarget ? 'Must specify a target file or folder.' :
42
42
  ambiguousTarget ? 'Target cannot be both a file and a folder.' :
43
- badTargetFolder ? 'Target folder cannot be written to: ' + targetFolder :
43
+ badTargetFolder ? 'Target folder cannot be written to: ' + String(targetFolder) :
44
44
  null;
45
45
  if (errorMessage)
46
- throw Error('[copy-file-util] ' + errorMessage);
46
+ throw new Error('[copy-file-util] ' + errorMessage);
47
47
  if (!skip && settings.move)
48
48
  fs.renameSync(source, target);
49
49
  else if (!skip)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "copy-file-util",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "description": "Copy or rename a file with optional package version number (CLI tool designed for use in npm package.json scripts)",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -40,32 +40,13 @@
40
40
  "node": true,
41
41
  "mocha": true
42
42
  },
43
- "eslintConfig": {
44
- "ignorePatterns": [
45
- "build",
46
- "dist",
47
- "node_modules"
48
- ],
49
- "root": true,
50
- "parser": "@typescript-eslint/parser",
51
- "plugins": [
52
- "@typescript-eslint"
53
- ],
54
- "extends": [
55
- "eslint:recommended",
56
- "plugin:@typescript-eslint/recommended"
57
- ],
58
- "rules": {
59
- "@typescript-eslint/no-non-null-assertion": "off"
60
- }
61
- },
62
43
  "runScriptsConfig": {
63
44
  "clean": [
64
45
  "rimraf build dist spec/fixtures/target"
65
46
  ],
66
47
  "lint": [
67
48
  "jshint . --exclude-path .gitignore",
68
- "eslint --max-warnings 0 . --ext .ts"
49
+ "eslint --max-warnings 0"
69
50
  ],
70
51
  "build": [
71
52
  "tsc",
@@ -77,24 +58,24 @@
77
58
  "test": "mocha spec/*.spec.js"
78
59
  },
79
60
  "dependencies": {
80
- "chalk": "~5.3",
61
+ "chalk": "~5.4",
81
62
  "cli-argv-util": "~1.2",
82
- "dna-engine": "~3.1",
63
+ "dna-engine": "~3.2",
83
64
  "fancy-log": "~2.0",
84
65
  "slash": "~5.1"
85
66
  },
86
67
  "devDependencies": {
68
+ "@eslint/js": "~9.21",
87
69
  "@types/fancy-log": "~2.0",
88
- "@types/node": "~20.12",
89
- "@typescript-eslint/eslint-plugin": "~7.7",
90
- "@typescript-eslint/parser": "~7.7",
70
+ "@types/node": "~22.13",
91
71
  "add-dist-header": "~1.4",
92
72
  "assert-deep-strict-equal": "~1.2",
93
- "eslint": "8.57.0",
73
+ "eslint": "~9.21",
94
74
  "jshint": "~2.13",
95
- "mocha": "~10.4",
96
- "rimraf": "~5.0",
97
- "run-scripts-util": "~1.2",
98
- "typescript": "~5.4"
75
+ "mocha": "~11.1",
76
+ "rimraf": "~6.0",
77
+ "run-scripts-util": "~1.3",
78
+ "typescript": "~5.8",
79
+ "typescript-eslint": "~8.26"
99
80
  }
100
81
  }