@node-minify/cli 7.0.0 → 7.1.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/lib/cli.js +3 -17
- package/lib/compress.js +1 -7
- package/lib/spinner.js +5 -13
- package/package.json +5 -5
package/lib/cli.js
CHANGED
|
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.run = void 0;
|
|
7
|
-
|
|
8
7
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
9
|
-
|
|
10
8
|
var _compress = require("./compress");
|
|
11
|
-
|
|
12
9
|
var _spinner = require("./spinner");
|
|
13
|
-
|
|
14
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
11
|
/*!
|
|
17
12
|
* node-minify
|
|
18
13
|
* Copyright(c) 2011-2022 Rodolphe Stoclin
|
|
@@ -27,10 +22,10 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
27
22
|
* Module variables.
|
|
28
23
|
*/
|
|
29
24
|
let silence = false;
|
|
25
|
+
|
|
30
26
|
/**
|
|
31
27
|
* Run one compressor.
|
|
32
28
|
*/
|
|
33
|
-
|
|
34
29
|
const runOne = cli => {
|
|
35
30
|
return new Promise((resolve, reject) => {
|
|
36
31
|
const compressor = typeof cli.compressor === 'string' ? require(`@node-minify/${cli.compressor}`) : cli.compressor;
|
|
@@ -40,44 +35,36 @@ const runOne = cli => {
|
|
|
40
35
|
input: cli.input.split(','),
|
|
41
36
|
output: cli.output
|
|
42
37
|
};
|
|
43
|
-
|
|
44
38
|
if (cli.option) {
|
|
45
39
|
options.options = JSON.parse(cli.option);
|
|
46
40
|
}
|
|
47
|
-
|
|
48
41
|
if (!silence) {
|
|
49
42
|
(0, _spinner.spinnerStart)(options);
|
|
50
43
|
}
|
|
51
|
-
|
|
52
44
|
return (0, _compress.compress)(options).then(result => {
|
|
53
45
|
if (!silence) {
|
|
54
46
|
(0, _spinner.spinnerStop)(result);
|
|
55
47
|
}
|
|
56
|
-
|
|
57
48
|
resolve(result);
|
|
58
49
|
}).catch(err => {
|
|
59
50
|
if (!silence) {
|
|
60
51
|
(0, _spinner.spinnerError)(options);
|
|
61
52
|
}
|
|
62
|
-
|
|
63
53
|
reject(err);
|
|
64
54
|
});
|
|
65
55
|
});
|
|
66
56
|
};
|
|
57
|
+
|
|
67
58
|
/**
|
|
68
59
|
* Run cli.
|
|
69
60
|
*/
|
|
70
|
-
|
|
71
|
-
|
|
72
61
|
const run = cli => {
|
|
73
62
|
silence = !!cli.silence;
|
|
74
|
-
|
|
75
63
|
if (!silence) {
|
|
76
64
|
console.log('');
|
|
77
65
|
console.log(_chalk.default.bgBlue.black(' INFO '), 'Starting compression...');
|
|
78
66
|
console.log('');
|
|
79
67
|
}
|
|
80
|
-
|
|
81
68
|
return new Promise((resolve, reject) => {
|
|
82
69
|
runOne(cli).then(() => {
|
|
83
70
|
if (!silence) {
|
|
@@ -88,9 +75,8 @@ const run = cli => {
|
|
|
88
75
|
}).then(resolve).catch(reject);
|
|
89
76
|
});
|
|
90
77
|
};
|
|
78
|
+
|
|
91
79
|
/**
|
|
92
80
|
* Expose `run()`.
|
|
93
81
|
*/
|
|
94
|
-
|
|
95
|
-
|
|
96
82
|
exports.run = run;
|
package/lib/compress.js
CHANGED
|
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.compress = void 0;
|
|
7
|
-
|
|
8
7
|
var _core = _interopRequireDefault(require("@node-minify/core"));
|
|
9
|
-
|
|
10
8
|
var _utils = require("@node-minify/utils");
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
10
|
/*!
|
|
15
11
|
* node-minify
|
|
16
12
|
* Copyright(c) 2011-2022 Rodolphe Stoclin
|
|
@@ -39,7 +35,6 @@ const compress = options => {
|
|
|
39
35
|
sizeGzip: 0
|
|
40
36
|
});
|
|
41
37
|
}
|
|
42
|
-
|
|
43
38
|
_utils.utils.getFilesizeGzippedInBytes(options.output).then(sizeGzip => {
|
|
44
39
|
resolve({
|
|
45
40
|
compressorLabel: options.compressorLabel,
|
|
@@ -51,9 +46,8 @@ const compress = options => {
|
|
|
51
46
|
}).catch(reject);
|
|
52
47
|
});
|
|
53
48
|
};
|
|
49
|
+
|
|
54
50
|
/**
|
|
55
51
|
* Expose `compress()`.
|
|
56
52
|
*/
|
|
57
|
-
|
|
58
|
-
|
|
59
53
|
exports.compress = compress;
|
package/lib/spinner.js
CHANGED
|
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.spinnerStop = exports.spinnerStart = exports.spinnerError = void 0;
|
|
7
|
-
|
|
8
7
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
9
|
-
|
|
10
8
|
var _ora = _interopRequireDefault(require("ora"));
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
10
|
/*!
|
|
15
11
|
* node-minify
|
|
16
12
|
* Copyright(c) 2011-2022 Rodolphe Stoclin
|
|
@@ -20,46 +16,42 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
20
16
|
/**
|
|
21
17
|
* Module dependencies.
|
|
22
18
|
*/
|
|
19
|
+
|
|
23
20
|
const spinner = (0, _ora.default)();
|
|
21
|
+
|
|
24
22
|
/**
|
|
25
23
|
* Start spinner.
|
|
26
24
|
*
|
|
27
25
|
* @param {Object} options
|
|
28
26
|
*/
|
|
29
|
-
|
|
30
27
|
const start = options => {
|
|
31
28
|
spinner.text = 'Compressing file(s) with ' + _chalk.default.green(options.compressorLabel) + '...';
|
|
32
29
|
spinner.start();
|
|
33
30
|
};
|
|
31
|
+
|
|
34
32
|
/**
|
|
35
33
|
* Stop spinner.
|
|
36
34
|
*
|
|
37
35
|
* @param {Object} result
|
|
38
36
|
*/
|
|
39
|
-
|
|
40
|
-
|
|
41
37
|
exports.spinnerStart = start;
|
|
42
|
-
|
|
43
38
|
const stop = result => {
|
|
44
39
|
spinner.text = 'File(s) compressed successfully with ' + _chalk.default.green(result.compressorLabel) + ' (' + _chalk.default.green(result.size) + ' minified, ' + _chalk.default.green(result.sizeGzip) + ' gzipped)';
|
|
45
40
|
spinner.succeed();
|
|
46
41
|
};
|
|
42
|
+
|
|
47
43
|
/**
|
|
48
44
|
* Mark spinner as failed.
|
|
49
45
|
*
|
|
50
46
|
* @param {Object} options
|
|
51
47
|
*/
|
|
52
|
-
|
|
53
|
-
|
|
54
48
|
exports.spinnerStop = stop;
|
|
55
|
-
|
|
56
49
|
const error = options => {
|
|
57
50
|
spinner.text = 'Error - file(s) not compressed with ' + _chalk.default.red(options.compressorLabel);
|
|
58
51
|
spinner.fail();
|
|
59
52
|
};
|
|
53
|
+
|
|
60
54
|
/**
|
|
61
55
|
* Expose `start(), stop() and error()`.
|
|
62
56
|
*/
|
|
63
|
-
|
|
64
|
-
|
|
65
57
|
exports.spinnerError = error;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@node-minify/cli",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.1.0",
|
|
4
4
|
"description": "CLI - command line interface for @node-minify",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"compressor",
|
|
@@ -36,12 +36,12 @@
|
|
|
36
36
|
"url": "https://github.com/srod/node-minify/issues"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@node-minify/core": "^7.
|
|
40
|
-
"@node-minify/utils": "^7.
|
|
39
|
+
"@node-minify/core": "^7.1.0",
|
|
40
|
+
"@node-minify/utils": "^7.1.0",
|
|
41
41
|
"chalk": "4.1.2",
|
|
42
|
-
"commander": "9.4.
|
|
42
|
+
"commander": "9.4.1",
|
|
43
43
|
"ora": "5.4.1",
|
|
44
44
|
"update-notifier": "6.0.2"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "94cef2d5d653c3bddc3e603b4e25c135b0b6f4b3"
|
|
47
47
|
}
|