@node-minify/utils 6.2.0 → 6.4.0
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 +1 -1
- package/lib/utils.js +75 -75
- package/package.json +3 -3
package/LICENSE
CHANGED
package/lib/utils.js
CHANGED
|
@@ -11,33 +11,33 @@ var _gzipSize = _interopRequireDefault(require("gzip-size"));
|
|
|
11
11
|
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
13
|
|
|
14
|
-
/*!
|
|
15
|
-
* node-minify
|
|
16
|
-
* Copyright(c) 2011-
|
|
17
|
-
* MIT Licensed
|
|
14
|
+
/*!
|
|
15
|
+
* node-minify
|
|
16
|
+
* Copyright(c) 2011-2022 Rodolphe Stoclin
|
|
17
|
+
* MIT Licensed
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
-
/**
|
|
21
|
-
* Module dependencies.
|
|
20
|
+
/**
|
|
21
|
+
* Module dependencies.
|
|
22
22
|
*/
|
|
23
23
|
const utils = {};
|
|
24
|
-
/**
|
|
25
|
-
* Read content from file.
|
|
26
|
-
*
|
|
27
|
-
* @param {String} file
|
|
28
|
-
* @returns {String}
|
|
24
|
+
/**
|
|
25
|
+
* Read content from file.
|
|
26
|
+
*
|
|
27
|
+
* @param {String} file
|
|
28
|
+
* @returns {String}
|
|
29
29
|
*/
|
|
30
30
|
|
|
31
31
|
exports.utils = utils;
|
|
32
32
|
|
|
33
33
|
utils.readFile = file => _fs.default.readFileSync(file, 'utf8');
|
|
34
|
-
/**
|
|
35
|
-
* Write content into file.
|
|
36
|
-
*
|
|
37
|
-
* @param {String} file
|
|
38
|
-
* @param {String} content
|
|
39
|
-
* @param {Number} index - index of the file being processed
|
|
40
|
-
* @returns {String}
|
|
34
|
+
/**
|
|
35
|
+
* Write content into file.
|
|
36
|
+
*
|
|
37
|
+
* @param {String} file
|
|
38
|
+
* @param {String} content
|
|
39
|
+
* @param {Number} index - index of the file being processed
|
|
40
|
+
* @returns {String}
|
|
41
41
|
*/
|
|
42
42
|
|
|
43
43
|
|
|
@@ -54,11 +54,11 @@ utils.writeFile = ({
|
|
|
54
54
|
|
|
55
55
|
return content;
|
|
56
56
|
};
|
|
57
|
-
/**
|
|
58
|
-
* Builds arguments array based on an object.
|
|
59
|
-
*
|
|
60
|
-
* @param {Object} options
|
|
61
|
-
* @returns {Array}
|
|
57
|
+
/**
|
|
58
|
+
* Builds arguments array based on an object.
|
|
59
|
+
*
|
|
60
|
+
* @param {Object} options
|
|
61
|
+
* @returns {Array}
|
|
62
62
|
*/
|
|
63
63
|
|
|
64
64
|
|
|
@@ -75,19 +75,19 @@ utils.buildArgs = options => {
|
|
|
75
75
|
});
|
|
76
76
|
return args;
|
|
77
77
|
};
|
|
78
|
-
/**
|
|
79
|
-
* Clone an object.
|
|
80
|
-
*
|
|
81
|
-
* @param {Object} obj
|
|
82
|
-
* @returns {Object}
|
|
78
|
+
/**
|
|
79
|
+
* Clone an object.
|
|
80
|
+
*
|
|
81
|
+
* @param {Object} obj
|
|
82
|
+
* @returns {Object}
|
|
83
83
|
*/
|
|
84
84
|
|
|
85
85
|
|
|
86
86
|
utils.clone = obj => JSON.parse(JSON.stringify(obj));
|
|
87
|
-
/**
|
|
88
|
-
* Get the file size in bytes.
|
|
89
|
-
*
|
|
90
|
-
* @returns {String}
|
|
87
|
+
/**
|
|
88
|
+
* Get the file size in bytes.
|
|
89
|
+
*
|
|
90
|
+
* @returns {String}
|
|
91
91
|
*/
|
|
92
92
|
|
|
93
93
|
|
|
@@ -97,10 +97,10 @@ utils.getFilesizeInBytes = file => {
|
|
|
97
97
|
const fileSizeInBytes = stats.size;
|
|
98
98
|
return utils.prettyBytes(fileSizeInBytes);
|
|
99
99
|
};
|
|
100
|
-
/**
|
|
101
|
-
* Get the gzipped file size in bytes.
|
|
102
|
-
*
|
|
103
|
-
* @returns {Promise.<String>}
|
|
100
|
+
/**
|
|
101
|
+
* Get the gzipped file size in bytes.
|
|
102
|
+
*
|
|
103
|
+
* @returns {Promise.<String>}
|
|
104
104
|
*/
|
|
105
105
|
|
|
106
106
|
|
|
@@ -113,11 +113,11 @@ utils.getFilesizeGzippedInBytes = file => {
|
|
|
113
113
|
});
|
|
114
114
|
});
|
|
115
115
|
};
|
|
116
|
-
/**
|
|
117
|
-
* Get the size in human readable.
|
|
118
|
-
* From https://github.com/sindresorhus/pretty-bytes
|
|
119
|
-
*
|
|
120
|
-
* @returns {String}
|
|
116
|
+
/**
|
|
117
|
+
* Get the size in human readable.
|
|
118
|
+
* From https://github.com/sindresorhus/pretty-bytes
|
|
119
|
+
*
|
|
120
|
+
* @returns {String}
|
|
121
121
|
*/
|
|
122
122
|
|
|
123
123
|
|
|
@@ -143,15 +143,15 @@ utils.prettyBytes = num => {
|
|
|
143
143
|
const unit = UNITS[exponent];
|
|
144
144
|
return (neg ? '-' : '') + numStr + ' ' + unit;
|
|
145
145
|
};
|
|
146
|
-
/**
|
|
147
|
-
* Set the file name as minified.
|
|
148
|
-
* eg. file.js returns file.min.js
|
|
149
|
-
*
|
|
150
|
-
* @param {String} file
|
|
151
|
-
* @param {String} output
|
|
152
|
-
* @param {String} publicFolder
|
|
153
|
-
* @param {Boolean} replaceInPlace
|
|
154
|
-
* @returns {String}
|
|
146
|
+
/**
|
|
147
|
+
* Set the file name as minified.
|
|
148
|
+
* eg. file.js returns file.min.js
|
|
149
|
+
*
|
|
150
|
+
* @param {String} file
|
|
151
|
+
* @param {String} output
|
|
152
|
+
* @param {String} publicFolder
|
|
153
|
+
* @param {Boolean} replaceInPlace
|
|
154
|
+
* @returns {String}
|
|
155
155
|
*/
|
|
156
156
|
|
|
157
157
|
|
|
@@ -170,10 +170,10 @@ utils.setFileNameMin = (file, output, publicFolder, replaceInPlace) => {
|
|
|
170
170
|
|
|
171
171
|
return output.replace('$1', fileWithoutExtension);
|
|
172
172
|
};
|
|
173
|
-
/**
|
|
174
|
-
* Compress a single file.
|
|
175
|
-
*
|
|
176
|
-
* @param {Object} settings
|
|
173
|
+
/**
|
|
174
|
+
* Compress a single file.
|
|
175
|
+
*
|
|
176
|
+
* @param {Object} settings
|
|
177
177
|
*/
|
|
178
178
|
|
|
179
179
|
|
|
@@ -187,11 +187,11 @@ utils.compressSingleFile = settings => {
|
|
|
187
187
|
content
|
|
188
188
|
});
|
|
189
189
|
};
|
|
190
|
-
/**
|
|
191
|
-
* Concatenate all input files and get the data.
|
|
192
|
-
*
|
|
193
|
-
* @param {String|Array} input
|
|
194
|
-
* @return {String}
|
|
190
|
+
/**
|
|
191
|
+
* Concatenate all input files and get the data.
|
|
192
|
+
*
|
|
193
|
+
* @param {String|Array} input
|
|
194
|
+
* @return {String}
|
|
195
195
|
*/
|
|
196
196
|
|
|
197
197
|
|
|
@@ -202,13 +202,13 @@ utils.getContentFromFiles = input => {
|
|
|
202
202
|
|
|
203
203
|
return input.map(path => !_fs.default.existsSync(path) || _fs.default.existsSync(path) && !_fs.default.lstatSync(path).isDirectory() ? _fs.default.readFileSync(path, 'utf8') : '').join('\n');
|
|
204
204
|
};
|
|
205
|
-
/**
|
|
206
|
-
* Run compressor in sync.
|
|
207
|
-
*
|
|
208
|
-
* @param {Object} settings
|
|
209
|
-
* @param {String} content
|
|
210
|
-
* @param {Number} index - index of the file being processed
|
|
211
|
-
* @return {String}
|
|
205
|
+
/**
|
|
206
|
+
* Run compressor in sync.
|
|
207
|
+
*
|
|
208
|
+
* @param {Object} settings
|
|
209
|
+
* @param {String} content
|
|
210
|
+
* @param {Number} index - index of the file being processed
|
|
211
|
+
* @return {String}
|
|
212
212
|
*/
|
|
213
213
|
|
|
214
214
|
|
|
@@ -222,13 +222,13 @@ utils.runSync = ({
|
|
|
222
222
|
callback: null,
|
|
223
223
|
index
|
|
224
224
|
});
|
|
225
|
-
/**
|
|
226
|
-
* Run compressor in async.
|
|
227
|
-
*
|
|
228
|
-
* @param {Object} settings
|
|
229
|
-
* @param {String} content
|
|
230
|
-
* @param {Number} index - index of the file being processed
|
|
231
|
-
* @return {Promise}
|
|
225
|
+
/**
|
|
226
|
+
* Run compressor in async.
|
|
227
|
+
*
|
|
228
|
+
* @param {Object} settings
|
|
229
|
+
* @param {String} content
|
|
230
|
+
* @param {Number} index - index of the file being processed
|
|
231
|
+
* @return {Promise}
|
|
232
232
|
*/
|
|
233
233
|
|
|
234
234
|
|
|
@@ -252,6 +252,6 @@ utils.runAsync = ({
|
|
|
252
252
|
});
|
|
253
253
|
});
|
|
254
254
|
};
|
|
255
|
-
/**
|
|
256
|
-
* Expose `utils`.
|
|
255
|
+
/**
|
|
256
|
+
* Expose `utils`.
|
|
257
257
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@node-minify/utils",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.4.0",
|
|
4
4
|
"description": "utils for @node-minify",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"compressor",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"main": "lib/utils.js",
|
|
14
14
|
"engines": {
|
|
15
|
-
"node": ">=
|
|
15
|
+
"node": ">=12.0.0"
|
|
16
16
|
},
|
|
17
17
|
"directories": {
|
|
18
18
|
"lib": "lib",
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"gzip-size": "6.0.0"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "d529747a661487597e9be510d3d9e2df1bc0f556"
|
|
38
38
|
}
|