clear_node_modules 1.2.3 → 1.2.6

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.
@@ -0,0 +1,30 @@
1
+ name: Node.js Package
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+
8
+ jobs:
9
+ build:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+ - uses: actions/setup-node@v4
14
+ with:
15
+ node-version: 20
16
+ - run: npm install
17
+
18
+ publish-npm:
19
+ needs: build
20
+ runs-on: ubuntu-latest
21
+ steps:
22
+ - uses: actions/checkout@v4
23
+ - uses: actions/setup-node@v4
24
+ with:
25
+ node-version: 20
26
+ registry-url: https://registry.npmjs.org/
27
+ - run: npm install
28
+ - run: npm publish
29
+ env:
30
+ NODE_AUTH_TOKEN: ${{ secrets.npm_token }}
package/bin.js CHANGED
@@ -1,32 +1,39 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const path = require('path')
4
- const config = require('./config.json')
5
- const clearDir = require('./src/lib')
3
+ const path = require("path");
4
+ const config = require("./config.json");
5
+ const clearDir = require("./src/lib");
6
6
 
7
- const argv = process.argv.slice(2)
7
+ const { version } = require("../package.json");
8
8
 
9
- const log = console.log
9
+ const args = process.argv.slice(2);
10
10
 
11
- const DIST_DIR = path.resolve(__dirname, argv[0] || config.dist_dir_path)
12
- const LIMIT_SIZE = argv[1] || config.dist_dir_size
13
- const NODE_MODULES = argv[2] || config.dist_dir_name
11
+ if (args.includes("-v") || args.includes("--version")) {
12
+ console.log(`cnm v${version}`);
13
+ process.exit(0);
14
+ }
15
+
16
+ const log = console.log;
17
+
18
+ const DIST_DIR = path.resolve(__dirname, argv[0] || config.dist_dir_path);
19
+ const LIMIT_SIZE = argv[1] || config.dist_dir_size;
20
+ const NODE_MODULES = argv[2] || config.dist_dir_name;
14
21
 
15
- let isHelp = false
22
+ let isHelp = false;
16
23
 
17
- argv.forEach(arg => {
18
- if (arg.match(/^(-+|\/)(h(elp)?|\?)$/)) isHelp = true
19
- })
24
+ argv.forEach((arg) => {
25
+ if (arg.match(/^(-+|\/)(h(elp)?|\?)$/)) isHelp = true;
26
+ });
20
27
 
21
- if (argv.length < 1) isHelp = true
28
+ if (argv.length < 1) isHelp = true;
22
29
 
23
30
  if (isHelp) {
24
- log('')
25
- log('useage: cnm <path> <limit(mb)> <distDir>')
26
- log('')
27
- log(' delete the specified folder!')
28
- log('')
29
- process.exit(1)
31
+ log("");
32
+ log("useage: cnm <path> <limit(mb)> <distDir>");
33
+ log("");
34
+ log(" delete the specified folder!");
35
+ log("");
36
+ process.exit(1);
30
37
  }
31
38
 
32
- clearDir(DIST_DIR, LIMIT_SIZE, NODE_MODULES)
39
+ clearDir(DIST_DIR, LIMIT_SIZE, NODE_MODULES);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clear_node_modules",
3
- "version": "1.2.3",
3
+ "version": "1.2.6",
4
4
  "description": "help you remove all large file of node_modules in dist dir!",
5
5
  "main": "index.js",
6
6
  "directories": {