copy-no-nm 0.26.8
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 +90 -0
- package/bin/copy-no-nm.js +19 -0
- package/dist/copy-no-nm.exe +0 -0
- package/package.json +31 -0
package/README.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# copy-no-nm
|
|
2
|
+
|
|
3
|
+
Recursively copy a directory to another location while skipping every `node_modules` folder. The copy preserves file creation times, modification times, access times, and attributes. Before copying, everything already in the destination folder is sent to the Windows Recycle Bin.
|
|
4
|
+
|
|
5
|
+
Built with Go. Distributed on npm with a small Node.js launcher.
|
|
6
|
+
|
|
7
|
+
## Requirements
|
|
8
|
+
|
|
9
|
+
- Windows (Recycle Bin integration and metadata preservation use Windows APIs)
|
|
10
|
+
- [Go 1.22+](https://go.dev/dl/) for building from source
|
|
11
|
+
- [pnpm](https://pnpm.io/) for npm scripts
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
copy-no-nm <source> <destination>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Example:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
copy-no-nm "C:\projects\my-app" "D:\backups\my-app"
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Behavior
|
|
26
|
+
|
|
27
|
+
1. Existing destination contents are cleared to the Recycle Bin using selective rules (`node_modules` folders are kept by default).
|
|
28
|
+
2. `<source>` is copied recursively into `<destination>`.
|
|
29
|
+
3. Any directory named `node_modules` is skipped during the copy.
|
|
30
|
+
4. File creation dates, timestamps, and attributes are preserved.
|
|
31
|
+
5. On error: Inspector Gadget is shown in red, then the app waits for a key press before closing.
|
|
32
|
+
6. On success: Inspector Gadget is shown in green for 1.5 seconds, then the app closes.
|
|
33
|
+
|
|
34
|
+
### Clearing the destination
|
|
35
|
+
|
|
36
|
+
By default, `node_modules` folders in the destination are **not** deleted. Other subfolders are removed as a whole unless they contain a nested `node_modules` folder; in that case the same rules are applied inside that subfolder.
|
|
37
|
+
|
|
38
|
+
Use `--remove-node-modules` to also send `node_modules` folders (including nested ones) to the Recycle Bin.
|
|
39
|
+
|
|
40
|
+
## Development
|
|
41
|
+
|
|
42
|
+
Install dependencies (no runtime npm packages; pnpm is used for scripts only):
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pnpm install
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Build the Windows executable (generates `assets/icon.ico` from `assets/icon-source.png`, embeds it via `goversioninfo`, then compiles):
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
pnpm run build
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Run directly:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
.\dist\copy-no-nm.exe <source> <destination>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Or via the npm bin shim after linking:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
pnpm link --global
|
|
64
|
+
copy-no-nm <source> <destination>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## npm scripts
|
|
68
|
+
|
|
69
|
+
| Script | Description |
|
|
70
|
+
|--------|-------------|
|
|
71
|
+
| `pnpm run build` | Generate icon, embed Windows resources, build `dist/copy-no-nm.exe` |
|
|
72
|
+
| `pnpm run prepublishOnly` | Build before publish (runs automatically on `npm publish`) |
|
|
73
|
+
| `pnpm run publish:npm` | Publish to npm (`--access public`) |
|
|
74
|
+
|
|
75
|
+
## Publishing to npm
|
|
76
|
+
|
|
77
|
+
This package ships a prebuilt Windows binary in `dist/` plus a Node launcher in `bin/copy-no-nm.js`.
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
pnpm run build
|
|
81
|
+
pnpm run publish:npm
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
For cross-platform npm installs, consider splitting platform-specific binaries into separate packages listed under `optionalDependencies`.
|
|
85
|
+
|
|
86
|
+
Replace the temporary icon by editing `assets/icon-source.png`, then run `pnpm run build` again.
|
|
87
|
+
|
|
88
|
+
## License
|
|
89
|
+
|
|
90
|
+
MIT
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { spawnSync } from 'node:child_process';
|
|
4
|
+
import { existsSync } from 'node:fs';
|
|
5
|
+
import { dirname, join } from 'node:path';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
|
|
8
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
const root = join(__dirname, '..');
|
|
10
|
+
const binaryName = process.platform === 'win32' ? 'copy-no-nm.exe' : 'copy-no-nm';
|
|
11
|
+
const binaryPath = join(root, 'dist', binaryName);
|
|
12
|
+
|
|
13
|
+
if (!existsSync(binaryPath)) {
|
|
14
|
+
console.error(`copy-no-nm: binary not found at ${binaryPath}. Run "pnpm run build" first.`);
|
|
15
|
+
process.exit(1);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const result = spawnSync(binaryPath, process.argv.slice(2), { stdio: 'inherit' });
|
|
19
|
+
process.exit(result.status ?? 1);
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "copy-no-nm",
|
|
3
|
+
"version": "0.26.8",
|
|
4
|
+
"description": "Copy from one folder to another without the nested node_modules folder",
|
|
5
|
+
"author": "Max Zakharzhevskyi",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"copy",
|
|
9
|
+
"node_modules",
|
|
10
|
+
"cli",
|
|
11
|
+
"windows",
|
|
12
|
+
"recycle-bin"
|
|
13
|
+
],
|
|
14
|
+
"type": "module",
|
|
15
|
+
"bin": {
|
|
16
|
+
"copy-no-nm": "./bin/copy-no-nm.js"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"bin",
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=18"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "node scripts/build.mjs",
|
|
27
|
+
"prepublishOnly": "pnpm run build",
|
|
28
|
+
"publish:npm": "npm publish --access public",
|
|
29
|
+
"test": "go test ./..."
|
|
30
|
+
}
|
|
31
|
+
}
|