js-build-tools 3.0.0 → 3.0.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/dist/build.js +59 -59
- package/dist/bundle.js +12 -12
- package/dist/bundleLint.js +17 -17
- package/dist/bundleMinify.js +8 -8
- package/dist/copyFonts.js +8 -8
- package/dist/default.js +15 -15
- package/dist/distLint.js +17 -17
- package/dist/distMinify.js +8 -8
- package/dist/partials/addToReadme.js +13 -13
- package/dist/partials/beginWatcher.js +9 -9
- package/dist/partials/distFor.js +16 -16
- package/dist/partials/distForSrc.js +9 -9
- package/dist/partials/distSeries.js +19 -19
- package/dist/partials/imagesFor.js +27 -27
- package/dist/partials/readmeTemplate.js +11 -11
- package/dist/partials/runOnChange.js +27 -27
- package/dist/partials/sassFor.js +20 -20
- package/dist/partials/tsFor.js +20 -20
- package/dist/partials.js +34 -34
- package/dist/test-helpers/setUp.js +51 -51
- package/dist/testFull.js +17 -17
- package/dist/testHelpers.js +8 -8
- package/dist/testQuick.js +19 -19
- package/dist/utilities/dotGet.js +42 -42
- package/dist/utilities/dotNotate.js +50 -50
- package/dist/utilities/dotSet.js +36 -36
- package/dist/utilities/isObject.js +4 -4
- package/dist/utilities/strAfter.js +14 -0
- package/dist/utilities/strBefore.js +14 -0
- package/dist/watchTest.js +13 -13
- package/functions/utilities/dotGet.js +2 -2
- package/functions/utilities/dotSet.js +2 -2
- package/functions/utilities/strAfter.js +13 -0
- package/functions/utilities/strBefore.js +13 -0
- package/package.json +4 -4
- package/vendor/array-union/index.js +30 -30
- package/vendor/easy-transform-stream/index.js +54 -58
- package/vendor/globby/gitignore.js +96 -100
- package/vendor/globby/index.js +191 -195
- package/vendor/globby/stream-utils.js +57 -57
- package/vendor/globby/to-path.js +19 -19
- package/vendor/gulp-imagemin/index.js +5 -9
- package/vendor/gulp-plugin-extras/index.js +42 -46
- package/vendor/gulp-plugin-extras/plugin-error.js +144 -144
- package/vendor/ignore/index.js +467 -467
- package/vendor/imagemin/index.js +90 -94
- package/vendor/imagemin-gifsicle/index.js +33 -37
- package/vendor/imagemin-mozjpeg/index.js +100 -104
- package/vendor/imagemin-mozjpeg/node_modules/execa/index.js +2 -6
- package/vendor/imagemin-mozjpeg/node_modules/execa/lib/kill.js +2 -2
- package/vendor/imagemin-mozjpeg/node_modules/execa/lib/stream.js +2 -6
- package/vendor/imagemin-optipng/index.js +43 -43
- package/vendor/imagemin-svgo/index.js +26 -26
- package/vendor/is-jpg/index.js +11 -11
- package/vendor/junk/index.js +48 -48
- package/vendor/mozjpeg/index.js +8 -8
- package/vendor/mozjpeg/lib/index.js +17 -17
- package/vendor/mozjpeg/package.json +49 -50
- package/vendor/mozjpeg/vendor/cjpeg +0 -0
- package/vendor/mozjpeg/vendor/source/mozjpeg.tar.gz +0 -0
- package/vendor/p-pipe/index.js +22 -26
- package/vendor/plur/index.js +31 -31
- package/vendor/pretty-bytes/index.js +70 -70
- package/vendor/slash/index.js +11 -11
package/vendor/imagemin/index.js
CHANGED
|
@@ -1,94 +1,90 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
require("core-js/modules/esnext.async-iterator.
|
|
9
|
-
require("core-js/modules/esnext.
|
|
10
|
-
require("core-js/modules/esnext.iterator.
|
|
11
|
-
require("core-js/modules/esnext.iterator.
|
|
12
|
-
require("core-js/modules/
|
|
13
|
-
require("
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
var
|
|
19
|
-
var
|
|
20
|
-
var
|
|
21
|
-
var
|
|
22
|
-
var
|
|
23
|
-
var
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
exportImagemin()
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = imagemin;
|
|
7
|
+
require("core-js/modules/esnext.async-iterator.filter.js");
|
|
8
|
+
require("core-js/modules/esnext.async-iterator.map.js");
|
|
9
|
+
require("core-js/modules/esnext.iterator.constructor.js");
|
|
10
|
+
require("core-js/modules/esnext.iterator.filter.js");
|
|
11
|
+
require("core-js/modules/esnext.iterator.map.js");
|
|
12
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
13
|
+
var _nodeBuffer = require("node:buffer");
|
|
14
|
+
var _nodeFs = require("node:fs");
|
|
15
|
+
var _nodeUtil = require("node:util");
|
|
16
|
+
var _nodePath = _interopRequireDefault(require("node:path"));
|
|
17
|
+
var _gracefulFs = _interopRequireDefault(require("graceful-fs"));
|
|
18
|
+
var _fileType = _interopRequireDefault(require("file-type"));
|
|
19
|
+
var _index = require("../globby/index.js");
|
|
20
|
+
var _index2 = _interopRequireDefault(require("../p-pipe/index.js"));
|
|
21
|
+
var _replaceExt = _interopRequireDefault(require("replace-ext"));
|
|
22
|
+
var _index3 = _interopRequireDefault(require("../junk/index.js"));
|
|
23
|
+
var _index4 = _interopRequireDefault(require("../slash/index.js"));
|
|
24
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
+
const readFile = (0, _nodeUtil.promisify)(_gracefulFs.default.readFile);
|
|
26
|
+
const writeFile = (0, _nodeUtil.promisify)(_gracefulFs.default.writeFile);
|
|
27
|
+
const handleFile = async (sourcePath, _ref) => {
|
|
28
|
+
let {
|
|
29
|
+
destination,
|
|
30
|
+
plugins = []
|
|
31
|
+
} = _ref;
|
|
32
|
+
if (plugins && !Array.isArray(plugins)) {
|
|
33
|
+
throw new TypeError('The `plugins` option should be an `Array`');
|
|
34
|
+
}
|
|
35
|
+
let data = await readFile(sourcePath);
|
|
36
|
+
data = await (plugins.length > 0 ? (0, _index2.default)(...plugins)(data) : data);
|
|
37
|
+
const {
|
|
38
|
+
ext
|
|
39
|
+
} = (await _fileType.default.fromBuffer(data)) || {
|
|
40
|
+
ext: _nodePath.default.extname(sourcePath)
|
|
41
|
+
};
|
|
42
|
+
let destinationPath = destination ? _nodePath.default.join(destination, _nodePath.default.basename(sourcePath)) : undefined;
|
|
43
|
+
destinationPath = ext === 'webp' ? (0, _replaceExt.default)(destinationPath, '.webp') : destinationPath;
|
|
44
|
+
const returnValue = {
|
|
45
|
+
data,
|
|
46
|
+
sourcePath,
|
|
47
|
+
destinationPath
|
|
48
|
+
};
|
|
49
|
+
if (!destinationPath) {
|
|
50
|
+
return returnValue;
|
|
51
|
+
}
|
|
52
|
+
await _nodeFs.promises.mkdir(_nodePath.default.dirname(returnValue.destinationPath), {
|
|
53
|
+
recursive: true
|
|
54
|
+
});
|
|
55
|
+
await writeFile(returnValue.destinationPath, returnValue.data);
|
|
56
|
+
return returnValue;
|
|
57
|
+
};
|
|
58
|
+
async function imagemin(input) {
|
|
59
|
+
let {
|
|
60
|
+
glob = true,
|
|
61
|
+
...options
|
|
62
|
+
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
63
|
+
if (!Array.isArray(input)) {
|
|
64
|
+
throw new TypeError("Expected an `Array`, got `".concat(typeof input, "`"));
|
|
65
|
+
}
|
|
66
|
+
const unixFilePaths = input.map(path => (0, _index4.default)(path));
|
|
67
|
+
const filePaths = glob ? await (0, _index.globby)(unixFilePaths, {
|
|
68
|
+
onlyFiles: true
|
|
69
|
+
}) : input;
|
|
70
|
+
return Promise.all(filePaths.filter(filePath => _index3.default.not(_nodePath.default.basename(filePath))).map(async filePath => {
|
|
71
|
+
try {
|
|
72
|
+
return await handleFile(filePath, options);
|
|
73
|
+
} catch (error) {
|
|
74
|
+
error.message = "Error occurred when handling file: ".concat(input, "\n\n").concat(error.stack);
|
|
75
|
+
throw error;
|
|
76
|
+
}
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
79
|
+
imagemin.buffer = async function (input) {
|
|
80
|
+
let {
|
|
81
|
+
plugins = []
|
|
82
|
+
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
83
|
+
if (!_nodeBuffer.Buffer.isBuffer(input)) {
|
|
84
|
+
throw new TypeError("Expected a `Buffer`, got `".concat(typeof input, "`"));
|
|
85
|
+
}
|
|
86
|
+
if (plugins.length === 0) {
|
|
87
|
+
return input;
|
|
88
|
+
}
|
|
89
|
+
return (0, _index2.default)(...plugins)(input);
|
|
90
|
+
};
|
|
@@ -1,37 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
exportImageminGifsicle()
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const execa = require('execa');
|
|
4
|
+
const gifsicle = require('gifsicle');
|
|
5
|
+
const isGif = require('is-gif');
|
|
6
|
+
module.exports = function () {
|
|
7
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
8
|
+
return async input => {
|
|
9
|
+
if (!Buffer.isBuffer(input)) {
|
|
10
|
+
throw new TypeError("Expected `input` to be of type `Buffer` but received type `".concat(typeof input, "`"));
|
|
11
|
+
}
|
|
12
|
+
if (!isGif(input)) {
|
|
13
|
+
return input;
|
|
14
|
+
}
|
|
15
|
+
const args = ['--no-warnings', '--no-app-extensions'];
|
|
16
|
+
if (options.interlaced) {
|
|
17
|
+
args.push('--interlace');
|
|
18
|
+
}
|
|
19
|
+
if (options.optimizationLevel) {
|
|
20
|
+
args.push("--optimize=".concat(options.optimizationLevel));
|
|
21
|
+
}
|
|
22
|
+
if (options.colors) {
|
|
23
|
+
args.push("--colors=".concat(options.colors));
|
|
24
|
+
}
|
|
25
|
+
const {
|
|
26
|
+
stdout
|
|
27
|
+
} = await execa(gifsicle, args, {
|
|
28
|
+
encoding: null,
|
|
29
|
+
input
|
|
30
|
+
});
|
|
31
|
+
return stdout;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
@@ -1,104 +1,100 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
var _default = exports.default = imageminMozjpeg;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
exportImageminMozjpeg()
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _nodeBuffer = require("node:buffer");
|
|
8
|
+
var _index = require("./node_modules/execa/index.js");
|
|
9
|
+
var _index2 = _interopRequireDefault(require("../is-jpg/index.js"));
|
|
10
|
+
var _index3 = _interopRequireDefault(require("../mozjpeg/index.js"));
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
+
const imageminMozjpeg = options => async buffer => {
|
|
13
|
+
options = {
|
|
14
|
+
trellis: true,
|
|
15
|
+
trellisDC: true,
|
|
16
|
+
overshoot: true,
|
|
17
|
+
...options
|
|
18
|
+
};
|
|
19
|
+
if (!_nodeBuffer.Buffer.isBuffer(buffer)) {
|
|
20
|
+
return Promise.reject(new TypeError('Expected a buffer'));
|
|
21
|
+
}
|
|
22
|
+
if (!(0, _index2.default)(buffer)) {
|
|
23
|
+
return Promise.resolve(buffer);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// TODO: Remove these sometime far in the future
|
|
27
|
+
if (options.fastcrush) {
|
|
28
|
+
return Promise.reject(new Error('Option `fastcrush` was renamed to `fastCrush`'));
|
|
29
|
+
}
|
|
30
|
+
if (options.maxmemory) {
|
|
31
|
+
return Promise.reject(new Error('Option `maxmemory` was renamed to `maxMemory`'));
|
|
32
|
+
}
|
|
33
|
+
if (options.notrellis) {
|
|
34
|
+
return Promise.reject(new Error('Option `notrellis` was renamed to `trellis` and inverted'));
|
|
35
|
+
}
|
|
36
|
+
if (options.noovershoot) {
|
|
37
|
+
return Promise.reject(new Error('Option `noovershoot` was renamed to `overshoot` and inverted'));
|
|
38
|
+
}
|
|
39
|
+
const args = [];
|
|
40
|
+
if (typeof options.quality !== 'undefined') {
|
|
41
|
+
args.push('-quality', options.quality);
|
|
42
|
+
}
|
|
43
|
+
if (options.progressive === false) {
|
|
44
|
+
args.push('-baseline');
|
|
45
|
+
}
|
|
46
|
+
if (options.targa) {
|
|
47
|
+
args.push('-targa');
|
|
48
|
+
}
|
|
49
|
+
if (options.revert) {
|
|
50
|
+
args.push('-revert');
|
|
51
|
+
}
|
|
52
|
+
if (options.fastCrush) {
|
|
53
|
+
args.push('-fastcrush');
|
|
54
|
+
}
|
|
55
|
+
if (typeof options.dcScanOpt !== 'undefined') {
|
|
56
|
+
args.push('-dc-scan-opt', options.dcScanOpt);
|
|
57
|
+
}
|
|
58
|
+
if (!options.trellis) {
|
|
59
|
+
args.push('-notrellis');
|
|
60
|
+
}
|
|
61
|
+
if (!options.trellisDC) {
|
|
62
|
+
args.push('-notrellis-dc');
|
|
63
|
+
}
|
|
64
|
+
if (options.tune) {
|
|
65
|
+
args.push("-tune-".concat(options.tune));
|
|
66
|
+
}
|
|
67
|
+
if (!options.overshoot) {
|
|
68
|
+
args.push('-noovershoot');
|
|
69
|
+
}
|
|
70
|
+
if (options.arithmetic) {
|
|
71
|
+
args.push('-arithmetic');
|
|
72
|
+
}
|
|
73
|
+
if (options.dct) {
|
|
74
|
+
args.push('-dct', options.dct);
|
|
75
|
+
}
|
|
76
|
+
if (options.quantBaseline) {
|
|
77
|
+
args.push('-quant-baseline', options.quantBaseline);
|
|
78
|
+
}
|
|
79
|
+
if (typeof options.quantTable !== 'undefined') {
|
|
80
|
+
args.push('-quant-table', options.quantTable);
|
|
81
|
+
}
|
|
82
|
+
if (options.smooth) {
|
|
83
|
+
args.push('-smooth', options.smooth);
|
|
84
|
+
}
|
|
85
|
+
if (options.maxMemory) {
|
|
86
|
+
args.push('-maxmemory', options.maxMemory);
|
|
87
|
+
}
|
|
88
|
+
if (options.sample) {
|
|
89
|
+
args.push('-sample', options.sample.join(','));
|
|
90
|
+
}
|
|
91
|
+
const {
|
|
92
|
+
stdout
|
|
93
|
+
} = await (0, _index.execa)(_index3.default, args, {
|
|
94
|
+
encoding: null,
|
|
95
|
+
input: buffer,
|
|
96
|
+
maxBuffer: Number.POSITIVE_INFINITY
|
|
97
|
+
});
|
|
98
|
+
return stdout;
|
|
99
|
+
};
|
|
100
|
+
var _default = exports.default = imageminMozjpeg;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
3
2
|
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
@@ -258,7 +257,4 @@ function execaNode(scriptPath, args) {
|
|
|
258
257
|
stdio,
|
|
259
258
|
shell: false
|
|
260
259
|
});
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
exportExeca()
|
|
260
|
+
}
|
|
@@ -7,7 +7,7 @@ exports.validateTimeout = exports.spawnedKill = exports.spawnedCancel = exports.
|
|
|
7
7
|
require("core-js/modules/es.promise.finally.js");
|
|
8
8
|
require("core-js/modules/web.dom-collections.iterator.js");
|
|
9
9
|
var _nodeOs = _interopRequireDefault(require("node:os"));
|
|
10
|
-
var _signalExit =
|
|
10
|
+
var _signalExit = require("signal-exit");
|
|
11
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
12
|
const DEFAULT_FORCE_KILL_TIMEOUT = 1000 * 5;
|
|
13
13
|
|
|
@@ -113,7 +113,7 @@ const setExitHandler = async (spawned, _ref5, timedPromise) => {
|
|
|
113
113
|
if (!cleanup || detached) {
|
|
114
114
|
return timedPromise;
|
|
115
115
|
}
|
|
116
|
-
const removeExitHandler = (0, _signalExit.
|
|
116
|
+
const removeExitHandler = (0, _signalExit.onExit)(() => {
|
|
117
117
|
spawned.kill();
|
|
118
118
|
});
|
|
119
119
|
return timedPromise.finally(() => {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
3
2
|
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
@@ -122,7 +121,4 @@ const validateInputSync = _ref5 => {
|
|
|
122
121
|
throw new TypeError('The `input` option cannot be a stream in sync mode');
|
|
123
122
|
}
|
|
124
123
|
};
|
|
125
|
-
exports.validateInputSync = validateInputSync;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
exportLib()
|
|
124
|
+
exports.validateInputSync = validateInputSync;
|
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const execBuffer = require('exec-buffer');
|
|
4
|
-
const isPng = require('is-png');
|
|
5
|
-
const optipng = require('optipng-bin');
|
|
6
|
-
module.exports = options => async buffer => {
|
|
7
|
-
options = {
|
|
8
|
-
optimizationLevel: 3,
|
|
9
|
-
bitDepthReduction: true,
|
|
10
|
-
colorTypeReduction: true,
|
|
11
|
-
paletteReduction: true,
|
|
12
|
-
interlaced: false,
|
|
13
|
-
errorRecovery: true,
|
|
14
|
-
...options
|
|
15
|
-
};
|
|
16
|
-
if (!Buffer.isBuffer(buffer)) {
|
|
17
|
-
throw new TypeError('Expected a buffer');
|
|
18
|
-
}
|
|
19
|
-
if (!isPng(buffer)) {
|
|
20
|
-
return buffer;
|
|
21
|
-
}
|
|
22
|
-
const arguments_ = ['-strip', 'all', '-clobber', '-o', options.optimizationLevel, '-out', execBuffer.output];
|
|
23
|
-
if (options.errorRecovery) {
|
|
24
|
-
arguments_.push('-fix');
|
|
25
|
-
}
|
|
26
|
-
if (!options.bitDepthReduction) {
|
|
27
|
-
arguments_.push('-nb');
|
|
28
|
-
}
|
|
29
|
-
if (typeof options.interlaced === 'boolean') {
|
|
30
|
-
arguments_.push('-i', options.interlaced ? '1' : '0');
|
|
31
|
-
}
|
|
32
|
-
if (!options.colorTypeReduction) {
|
|
33
|
-
arguments_.push('-nc');
|
|
34
|
-
}
|
|
35
|
-
if (!options.paletteReduction) {
|
|
36
|
-
arguments_.push('-np');
|
|
37
|
-
}
|
|
38
|
-
arguments_.push(execBuffer.input);
|
|
39
|
-
return execBuffer({
|
|
40
|
-
input: buffer,
|
|
41
|
-
bin: optipng,
|
|
42
|
-
args: arguments_
|
|
43
|
-
});
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const execBuffer = require('exec-buffer');
|
|
4
|
+
const isPng = require('is-png');
|
|
5
|
+
const optipng = require('optipng-bin');
|
|
6
|
+
module.exports = options => async buffer => {
|
|
7
|
+
options = {
|
|
8
|
+
optimizationLevel: 3,
|
|
9
|
+
bitDepthReduction: true,
|
|
10
|
+
colorTypeReduction: true,
|
|
11
|
+
paletteReduction: true,
|
|
12
|
+
interlaced: false,
|
|
13
|
+
errorRecovery: true,
|
|
14
|
+
...options
|
|
15
|
+
};
|
|
16
|
+
if (!Buffer.isBuffer(buffer)) {
|
|
17
|
+
throw new TypeError('Expected a buffer');
|
|
18
|
+
}
|
|
19
|
+
if (!isPng(buffer)) {
|
|
20
|
+
return buffer;
|
|
21
|
+
}
|
|
22
|
+
const arguments_ = ['-strip', 'all', '-clobber', '-o', options.optimizationLevel, '-out', execBuffer.output];
|
|
23
|
+
if (options.errorRecovery) {
|
|
24
|
+
arguments_.push('-fix');
|
|
25
|
+
}
|
|
26
|
+
if (!options.bitDepthReduction) {
|
|
27
|
+
arguments_.push('-nb');
|
|
28
|
+
}
|
|
29
|
+
if (typeof options.interlaced === 'boolean') {
|
|
30
|
+
arguments_.push('-i', options.interlaced ? '1' : '0');
|
|
31
|
+
}
|
|
32
|
+
if (!options.colorTypeReduction) {
|
|
33
|
+
arguments_.push('-nc');
|
|
34
|
+
}
|
|
35
|
+
if (!options.paletteReduction) {
|
|
36
|
+
arguments_.push('-np');
|
|
37
|
+
}
|
|
38
|
+
arguments_.push(execBuffer.input);
|
|
39
|
+
return execBuffer({
|
|
40
|
+
input: buffer,
|
|
41
|
+
bin: optipng,
|
|
42
|
+
args: arguments_
|
|
43
|
+
});
|
|
44
44
|
};
|