@adamlui/minify.js 1.1.0 → 1.1.2

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.
Files changed (3) hide show
  1. package/README.md +4 -3
  2. package/minify.js +8 -7
  3. package/package.json +3 -3
package/README.md CHANGED
@@ -2,14 +2,15 @@
2
2
 
3
3
  ### Recursively minify all JavaScript files.
4
4
 
5
- <a href="https://www.npmjs.com/package/@adamlui/minify.js"><img height=31 src="https://img.shields.io/badge/Latest_Build-1.1.0-fc7811.svg?logo=npm&logoColor=white&labelColor=464646&style=for-the-badge"></a>
5
+ <a href="https://www.npmjs.com/package/@adamlui/minify.js"><img height=31 src="https://img.shields.io/npm/dt/%40adamlui%2Fminify.js?logo=npm&logoColor=white&labelColor=46464&style=for-the-badge"></a>
6
6
  <a href="#%EF%B8%8F-mit-license"><img height=31 src="https://img.shields.io/badge/License-MIT-fcde7b.svg?logo=internetarchive&logoColor=white&labelColor=464646&style=for-the-badge"></a>
7
+ <a href="https://www.npmjs.com/package/@adamlui/minify.js?activeTab=versions"><img height=31 src="https://img.shields.io/badge/Latest_Build-1.1.2-fc7811.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
7
8
 
8
9
  <img src="https://github.com/adamlui/js-utils/blob/main/minify.js/media/images/minify-js-docs-demo.png">
9
10
 
10
11
  <br>
11
12
 
12
- <img height=8px width="100%" src="https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/aqua.png">
13
+ <img height=8px width="100%" src="https://raw.githubusercontent.com/adamlui/js-utils/main/docs/images/aqua-separator.png">
13
14
 
14
15
  ## ⚡ Installation
15
16
 
@@ -109,7 +110,7 @@ SOFTWARE.
109
110
 
110
111
  <br>
111
112
 
112
- <img height=6px width="100%" src="https://raw.githubusercontent.com/andreasbm/readme/master/assets/lines/aqua.png">
113
+ <img height=6px width="100%" src="https://raw.githubusercontent.com/adamlui/js-utils/main/docs/images/aqua-separator.png">
113
114
 
114
115
  <a href="https://github.com/adamlui/js-utils">**Home**</a> /
115
116
  <a href="https://github.com/adamlui/js-utils/discussions">Discuss</a> /
package/minify.js CHANGED
@@ -13,15 +13,17 @@ const nc = '\x1b[0m', // no color
13
13
 
14
14
  // Init I/O args
15
15
  const [inputArg = '', outputArg = ''] = ( // default to empty strings for error-less handling
16
- process.argv.slice(2) // exclude executable and script path
16
+ process.argv.slice(2) // exclude executable and script paths
17
17
  .filter(arg => !arg.startsWith('-')) // exclude flags
18
18
  .map(arg => arg.replace(/^\/*/, '')) // clean leading slashes to avoid parsing system root
19
19
  );
20
20
 
21
21
  // Validate input arg (output arg can be anything)
22
- if (inputArg && !fs.existsSync(inputArg)) {
23
- console.error(`\n${br}Error: First arg must be an existing file or directory.${nc}`
24
- + '\nExample valid command: \n>> minify-js . output.min.js');
22
+ const inputPath = path.resolve(process.cwd(), inputArg);
23
+ if (inputArg && !fs.existsSync(inputPath)) {
24
+ console.error(`\n${br}Error: First arg must be an existing file or directory.`
25
+ + `\n${ inputPath } does not exist.${nc}`
26
+ + '\n\nExample valid command: \n>> minify-js . output.min.js');
25
27
  process.exit(1);
26
28
  }
27
29
 
@@ -32,8 +34,7 @@ const config = {
32
34
  };
33
35
 
34
36
  // Recursively find all eligible JavaScript files or arg-passed file
35
- const inputPath = path.resolve(process.cwd(), inputArg),
36
- jsFiles = [];
37
+ const jsFiles = [];
37
38
  if (inputArg.endsWith('.js')) jsFiles.push(inputPath);
38
39
  else (function findJSfiles(dir) {
39
40
  const files = fs.readdirSync(dir);
@@ -44,7 +45,7 @@ else (function findJSfiles(dir) {
44
45
  findJSfiles(filePath); // recursively find unminified JS in eligible dir
45
46
  else if (/\.js(?<!\.min\.js)$/.test(file) &&
46
47
  (config.includeDotFiles || !file.startsWith('.')))
47
- jsFiles.push(filePath); // store eligible unminified JS file for compilation
48
+ jsFiles.push(filePath); // store eligible unminified JS file for minification
48
49
  });
49
50
  })(inputPath);
50
51
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@adamlui/minify.js",
3
- "version": "1.1.0",
4
- "description": "Minify JavaScript files",
3
+ "version": "1.1.2",
4
+ "description": "Recursively minify all JavaScript files",
5
5
  "author": {
6
6
  "name": "Adam Lui",
7
7
  "email": "adam@kudoai.com",
@@ -14,7 +14,7 @@
14
14
  "minify-js": "minify.js"
15
15
  },
16
16
  "scripts": {
17
- "test": "echo \"Error: no test specified\" && exit 1",
17
+ "test": "bash utils/test/minify.test.sh",
18
18
  "bump:patch": "bash utils/bump.sh patch",
19
19
  "bump:minor": "bash utils/bump.sh minor",
20
20
  "bump:major": "bash utils/bump.sh major",