copy-file-util 1.3.3 → 1.3.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-file-util
3
+ Copyright (c) 2022-2026 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
@@ -49,15 +49,16 @@ You can also install **copy-file-util** globally (`--global`) and then run it an
49
49
 
50
50
  ### 4. CLI flags
51
51
  Command-line flags:
52
- | Flag | Description | Values |
53
- | ---------------- | ------------------------------------------------ | ---------- |
54
- | `--cd` | Change working directory before starting copy. | **string** |
55
- | `--folder` | Indicates the target is a folder. | N/A |
56
- | `--move` | Delete the source file after copying it. | N/A |
57
- | `--no-overwrite` | Abort if target file already exists. | N/A |
58
- | `--note` | Place to add a comment only for humans. | **string** |
59
- | `--platform-eol` | Save target file with OS dependent line endings. | N/A |
60
- | `--quiet` | Suppress informational messages. | N/A |
52
+ | Flag | Description | Values |
53
+ | ------------------ | ------------------------------------------------ | ---------- |
54
+ | `--cd` | Change working directory before starting copy. | **string** |
55
+ | `--folder` | Indicates the target is a folder. | N/A |
56
+ | `--move` | Delete the source file after copying it. | N/A |
57
+ | `--no-overwrite` | Abort if target file already exists. | N/A |
58
+ | `--note` | Place to add a comment only for humans. | **string** |
59
+ | `--platform-eol` | Save target file with OS dependent line endings. | N/A |
60
+ | `--quiet` | Suppress informational messages. | N/A |
61
+ | `--remove-sem-ver` | Deletes text like 'v1.2.3' to avoid noisy diffs. | N/A |
61
62
 
62
63
  ### 5. Examples
63
64
  - `copy-file app.js app.mjs --quiet`<br>
@@ -1,4 +1,4 @@
1
- //! copy-file-util v1.3.3 ~~ https://github.com/center-key/copy-file-util ~~ MIT License
1
+ //! copy-file-util v1.3.4 ~~ https://github.com/center-key/copy-file-util ~~ MIT License
2
2
 
3
3
  export type Settings = {
4
4
  cd: string | null;
@@ -8,6 +8,7 @@ export type Settings = {
8
8
  move: boolean;
9
9
  overwrite: boolean;
10
10
  platformEol: boolean;
11
+ removeSemVer: boolean;
11
12
  };
12
13
  export type Result = {
13
14
  origin: string;
package/dist/copy-file.js CHANGED
@@ -1,4 +1,4 @@
1
- //! copy-file-util v1.3.3 ~~ https://github.com/center-key/copy-file-util ~~ MIT License
1
+ //! copy-file-util v1.3.4 ~~ https://github.com/center-key/copy-file-util ~~ MIT License
2
2
 
3
3
  import { cliArgvUtil } from 'cli-argv-util';
4
4
  import { dna } from 'dna-engine';
@@ -14,7 +14,8 @@ const copyFile = {
14
14
  throw new Error(`[copy-file-util] ${message}`);
15
15
  },
16
16
  cli() {
17
- const validFlags = ['cd', 'folder', 'move', 'no-overwrite', 'note', 'platform-eol', 'quiet'];
17
+ const validFlags = ['cd', 'folder', 'move', 'no-overwrite', 'note', 'platform-eol',
18
+ 'quiet', 'remove-sem-ver'];
18
19
  const cli = cliArgvUtil.parse(validFlags);
19
20
  const source = cli.params[0];
20
21
  const target = cli.params[1];
@@ -40,6 +41,7 @@ const copyFile = {
40
41
  move: !!cli.flagOn.move,
41
42
  overwrite: !cli.flagOn.noOverwrite,
42
43
  platformEol: !!cli.flagOn.platformEol,
44
+ removeSemVer: !!cli.flagOn.removeSemVer,
43
45
  };
44
46
  const result = copyFile.cp(source, options);
45
47
  if (!cli.flagOn.quiet)
@@ -54,6 +56,7 @@ const copyFile = {
54
56
  move: false,
55
57
  overwrite: true,
56
58
  platformEol: false,
59
+ removeSemVer: false,
57
60
  };
58
61
  const settings = { ...defaults, ...options };
59
62
  const startTime = Date.now();
@@ -84,14 +87,21 @@ const copyFile = {
84
87
  badTargetFolder ? 'Target folder cannot be written to: ' + String(targetFolder) :
85
88
  null;
86
89
  copyFile.assert(!error, error);
90
+ const rewriteTarget = () => {
91
+ const semVer = /\s+v[0-9]+\.[0-9]+\.[0-9]+\s+/;
92
+ const content1 = fs.readFileSync(target, 'utf-8');
93
+ const content2 = settings.platformEol ? content1.replace(/\r?\n/g, EOL) : content1;
94
+ const content3 = settings.removeSemVer ? content2.replace(semVer, ' ') : content2;
95
+ if (content1 !== content3)
96
+ fs.writeFileSync(target, content3);
97
+ };
87
98
  const createTarget = () => {
88
99
  if (settings.move)
89
100
  fs.renameSync(source, target);
90
101
  else
91
102
  fs.copyFileSync(source, target);
92
- const platformEol = (text) => text.replace(/\r?\n/g, EOL);
93
- if (settings.platformEol)
94
- fs.writeFileSync(target, platformEol(fs.readFileSync(target, 'utf-8')));
103
+ if (settings.platformEol || settings.removeSemVer)
104
+ rewriteTarget();
95
105
  };
96
106
  if (!skip)
97
107
  createTarget();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "copy-file-util",
3
- "version": "1.3.3",
3
+ "version": "1.3.4",
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",
@@ -76,6 +76,6 @@
76
76
  "rimraf": "~6.1",
77
77
  "run-scripts-util": "~1.3",
78
78
  "typescript": "~5.9",
79
- "typescript-eslint": "~8.50"
79
+ "typescript-eslint": "~8.52"
80
80
  }
81
81
  }