@adamlui/minify.js 1.4.1 → 1.4.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.
- package/README.md +7 -7
- package/docs/LICENSE.md +3 -2
- package/docs/SECURITY.md +2 -1
- package/minify.js +7 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,17 +9,18 @@
|
|
|
9
9
|
<a href="https://github.com/adamlui/js-utils/tree/main/minify.js/docs/zh-tw#readme">繁體中文</a> |
|
|
10
10
|
<a href="https://github.com/adamlui/js-utils/tree/main/minify.js/docs/hi#readme">हिंदी</a> |
|
|
11
11
|
<a href="https://github.com/adamlui/js-utils/tree/main/minify.js/docs/bn#readme">বাংলা</a> |
|
|
12
|
-
<a href="https://github.com/adamlui/js-utils/tree/main/minify.js/docs/mr#readme">मराठी</a>
|
|
12
|
+
<a href="https://github.com/adamlui/js-utils/tree/main/minify.js/docs/mr#readme">मराठी</a> |
|
|
13
|
+
<a href="https://github.com/adamlui/js-utils/tree/main/minify.js/docs/pa#readme">ਪੰਜਾਬੀ</a>
|
|
13
14
|
</h6>
|
|
14
15
|
</div>
|
|
15
16
|
|
|
16
|
-
# </> minify.js
|
|
17
|
+
# </> minify.js
|
|
17
18
|
|
|
18
19
|
### Recursively minify all JavaScript files.
|
|
19
20
|
|
|
20
21
|
<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=464646&style=for-the-badge"></a>
|
|
21
22
|
<a href="#%EF%B8%8F-mit-license"><img height=31 src="https://img.shields.io/badge/License-MIT-red.svg?logo=internetarchive&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
22
|
-
<a href="https://www.npmjs.com/package/@adamlui/minify.js?activeTab=versions"><img height=31 src="https://img.shields.io/badge/Latest_Build-1.4.
|
|
23
|
+
<a href="https://www.npmjs.com/package/@adamlui/minify.js?activeTab=versions"><img height=31 src="https://img.shields.io/badge/Latest_Build-1.4.2-fc7811.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
23
24
|
<a href="https://www.npmjs.com/package/@adamlui/minify.js?activeTab=code"><img height=31 src="https://img.shields.io/npm/unpacked-size/%40adamlui%2Fminify.js?style=for-the-badge&logo=ebox&logoColor=white&labelColor=464646&color=blue"></a>
|
|
24
25
|
<a href="https://sonarcloud.io/component_measures?metric=new_vulnerabilities&id=adamlui_js-utils:minify.js/minify.js"><img height=31 src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsonarcloud.io%2Fapi%2Fmeasures%2Fcomponent%3Fcomponent%3Dadamlui_js-utils%3Aminify.js%2Fminify.js%26metricKeys%3Dvulnerabilities&query=%24.component.measures.0.value&style=for-the-badge&logo=sonarcloud&logoColor=white&labelColor=464646&label=Vulnerabilities&color=gold"></a>
|
|
25
26
|
|
|
@@ -164,9 +165,8 @@ If a **directory path** is passed, JavaScript files are searched for (recursivel
|
|
|
164
165
|
```js
|
|
165
166
|
const results = minifyJS.minify('.');
|
|
166
167
|
results.forEach(result =>
|
|
167
|
-
console.log(result.srcPath) // paths to JS files in working directory + all nested directories
|
|
168
|
-
);
|
|
169
|
-
console.log(results[1].code) // minified code of 2nd JS file if found, or `undefined` if not found
|
|
168
|
+
console.log(result.srcPath)); // paths to JS files in working directory + all nested directories
|
|
169
|
+
console.log(results[1].code); // minified code of 2nd JS file if found, or `undefined` if not found
|
|
170
170
|
```
|
|
171
171
|
|
|
172
172
|
Options are boolean, passed as object properties. For example:
|
|
@@ -217,7 +217,7 @@ Please consider [giving a GitHub ⭐](https://github.com/adamlui/js-utils) if th
|
|
|
217
217
|
|
|
218
218
|
## 🏛️ MIT License
|
|
219
219
|
|
|
220
|
-
**Copyright © 2023–2024 [Adam Lui](https://github.com/adamlui)**
|
|
220
|
+
**Copyright © 2023–2024 [Adam Lui](https://github.com/adamlui) & contributors**
|
|
221
221
|
|
|
222
222
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
223
223
|
|
package/docs/LICENSE.md
CHANGED
|
@@ -9,13 +9,14 @@
|
|
|
9
9
|
<a href="zh-tw/LICENSE.md">繁體中文</a> |
|
|
10
10
|
<a href="hi/LICENSE.md">हिंदी</a> |
|
|
11
11
|
<a href="bn/LICENSE.md">বাংলা</a> |
|
|
12
|
-
<a href="mr/LICENSE.md">मराठी</a>
|
|
12
|
+
<a href="mr/LICENSE.md">मराठी</a> |
|
|
13
|
+
<a href="pa/LICENSE.md">ਪੰਜਾਬੀ</a>
|
|
13
14
|
</h6>
|
|
14
15
|
</div>
|
|
15
16
|
|
|
16
17
|
# 🏛️ MIT License
|
|
17
18
|
|
|
18
|
-
**Copyright © 2023–2024 [Adam Lui](https://github.com/adamlui)**
|
|
19
|
+
**Copyright © 2023–2024 [Adam Lui](https://github.com/adamlui) & contributors**
|
|
19
20
|
|
|
20
21
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
21
22
|
|
package/docs/SECURITY.md
CHANGED
package/minify.js
CHANGED
|
@@ -13,17 +13,17 @@ function findJS(searchDir, options = {}) {
|
|
|
13
13
|
const dirFiles = fs.readdirSync(searchDir), jsFiles = [];
|
|
14
14
|
dirFiles.forEach(file => {
|
|
15
15
|
const filePath = path.resolve(searchDir, file);
|
|
16
|
-
if (fs.statSync(filePath).isDirectory() && file != 'node_modules'
|
|
17
|
-
(options.dotFolders || !file.startsWith('.')) && options.recursive) {
|
|
16
|
+
if (fs.statSync(filePath).isDirectory() && file != 'node_modules'
|
|
17
|
+
&& (options.dotFolders || !file.startsWith('.')) && options.recursive) {
|
|
18
18
|
if (options.verbose) console.info(`Searching for unminified JS files in: ${filePath}...`);
|
|
19
19
|
jsFiles.push( // recursively find unminified JS in eligible dir
|
|
20
20
|
...findJS(filePath, { ...options, isRecursing: true }));
|
|
21
|
-
} else if (/\.js(?<!\.min\.js)$/.test(file)
|
|
22
|
-
(options.dotFiles || !file.startsWith('.')))
|
|
21
|
+
} else if (/\.js(?<!\.min\.js)$/.test(file)
|
|
22
|
+
&& (options.dotFiles || !file.startsWith('.')))
|
|
23
23
|
jsFiles.push(filePath); // store eligible unminified JS file for minification
|
|
24
24
|
});
|
|
25
25
|
if (options.isRecursing || jsFiles.length > 0) return jsFiles;
|
|
26
|
-
else console.info('\nNo unminified JavaScript files found.');
|
|
26
|
+
else if (options.verbose) console.info('\nNo unminified JavaScript files found.');
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
function minify(input, options = {}) {
|
|
@@ -41,6 +41,7 @@ function minify(input, options = {}) {
|
|
|
41
41
|
if (minifyResult.error) console.error(`ERROR: ${ minifyResult.error.message }`);
|
|
42
42
|
return { code: minifyResult.code, srcPath: input, error: minifyResult.error };
|
|
43
43
|
} else { // dir path passed
|
|
44
|
+
if (options.verbose) console.info('Searching for unminified JS files...');
|
|
44
45
|
return findJS(input, { recursive: options.recursive,
|
|
45
46
|
dotFolders: options.dotFolders, dotFiles: options.dotFiles })
|
|
46
47
|
?.map(jsPath => { // minify found JS files
|
|
@@ -130,6 +131,7 @@ else { // run as CLI tool
|
|
|
130
131
|
}
|
|
131
132
|
|
|
132
133
|
// Find all eligible JavaScript files or arg-passed file
|
|
134
|
+
printIfNotQuiet('Searching for unminified JS files...');
|
|
133
135
|
const unminnedJSfiles = inputArg.endsWith('.js') ? [inputPath]
|
|
134
136
|
: findJS(inputPath, { recursive: !config.noRecursion });
|
|
135
137
|
|
|
@@ -138,7 +140,6 @@ else { // run as CLI tool
|
|
|
138
140
|
unminnedJSfiles?.forEach(file => console.info(file));
|
|
139
141
|
|
|
140
142
|
} else { // actually minify JavaScript files
|
|
141
|
-
printIfNotQuiet(''); // line break before first log
|
|
142
143
|
|
|
143
144
|
// Build array of minification data
|
|
144
145
|
const failedPaths = [];
|