@node-minify/run 7.1.0 → 8.0.0-beta.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/dist/index.d.ts +19 -0
- package/dist/index.js +88 -0
- package/dist/index.mjs +58 -0
- package/package.json +22 -6
- package/lib/run.js +0 -119
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { MinifierOptions } from '@node-minify/types';
|
|
2
|
+
|
|
3
|
+
/*!
|
|
4
|
+
* node-minify
|
|
5
|
+
* Copyright(c) 2011-2022 Rodolphe Stoclin
|
|
6
|
+
* MIT Licensed
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Run the command line with spawn.
|
|
11
|
+
*
|
|
12
|
+
* @param {Array} args
|
|
13
|
+
* @param {String} data
|
|
14
|
+
* @param {Object} settings
|
|
15
|
+
* @param {Function} callback
|
|
16
|
+
*/
|
|
17
|
+
declare const runCommandLine: ({ args, data, settings, callback }: MinifierOptions) => any;
|
|
18
|
+
|
|
19
|
+
export { runCommandLine };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
|
|
25
|
+
// src/index.ts
|
|
26
|
+
var src_exports = {};
|
|
27
|
+
__export(src_exports, {
|
|
28
|
+
runCommandLine: () => runCommandLine
|
|
29
|
+
});
|
|
30
|
+
module.exports = __toCommonJS(src_exports);
|
|
31
|
+
var import_child_process = __toESM(require("child_process"));
|
|
32
|
+
var runCommandLine = ({ args, data, settings, callback }) => {
|
|
33
|
+
if (settings && settings.sync) {
|
|
34
|
+
return runSync({ settings, data, args, callback });
|
|
35
|
+
}
|
|
36
|
+
return runAsync({ data, args, callback });
|
|
37
|
+
};
|
|
38
|
+
var runAsync = ({ data, args, callback }) => {
|
|
39
|
+
let stdout = "";
|
|
40
|
+
let stderr = "";
|
|
41
|
+
const child = import_child_process.default.spawn("java", args, {
|
|
42
|
+
stdio: "pipe"
|
|
43
|
+
});
|
|
44
|
+
child.on("error", console.log.bind(console, "child"));
|
|
45
|
+
child.stdin.on("error", console.log.bind(console, "child.stdin"));
|
|
46
|
+
child.stdout.on("error", console.log.bind(console, "child.stdout"));
|
|
47
|
+
child.stderr.on("error", console.log.bind(console, "child.stderr"));
|
|
48
|
+
child.on("exit", (code) => {
|
|
49
|
+
if (code !== 0) {
|
|
50
|
+
return callback && callback(new Error(stderr));
|
|
51
|
+
}
|
|
52
|
+
return callback && callback(null, stdout);
|
|
53
|
+
});
|
|
54
|
+
child.stdout.on("data", (chunk) => {
|
|
55
|
+
stdout += chunk;
|
|
56
|
+
});
|
|
57
|
+
child.stderr.on("data", (chunk) => {
|
|
58
|
+
stderr += chunk;
|
|
59
|
+
});
|
|
60
|
+
child.stdin.end(data);
|
|
61
|
+
};
|
|
62
|
+
var runSync = ({ settings, data, args, callback }) => {
|
|
63
|
+
try {
|
|
64
|
+
const child = import_child_process.default.spawnSync("java", args, {
|
|
65
|
+
input: data,
|
|
66
|
+
stdio: "pipe",
|
|
67
|
+
maxBuffer: settings && settings.buffer
|
|
68
|
+
});
|
|
69
|
+
const stdout = child.stdout.toString();
|
|
70
|
+
const stderr = child.stderr.toString();
|
|
71
|
+
const code = child.status;
|
|
72
|
+
if (code !== 0) {
|
|
73
|
+
return callback && callback(new Error(stderr));
|
|
74
|
+
}
|
|
75
|
+
return callback && callback(null, stdout);
|
|
76
|
+
} catch (err) {
|
|
77
|
+
return callback && callback(err);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
81
|
+
0 && (module.exports = {
|
|
82
|
+
runCommandLine
|
|
83
|
+
});
|
|
84
|
+
/*!
|
|
85
|
+
* node-minify
|
|
86
|
+
* Copyright(c) 2011-2022 Rodolphe Stoclin
|
|
87
|
+
* MIT Licensed
|
|
88
|
+
*/
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import childProcess from "child_process";
|
|
3
|
+
var runCommandLine = ({ args, data, settings, callback }) => {
|
|
4
|
+
if (settings && settings.sync) {
|
|
5
|
+
return runSync({ settings, data, args, callback });
|
|
6
|
+
}
|
|
7
|
+
return runAsync({ data, args, callback });
|
|
8
|
+
};
|
|
9
|
+
var runAsync = ({ data, args, callback }) => {
|
|
10
|
+
let stdout = "";
|
|
11
|
+
let stderr = "";
|
|
12
|
+
const child = childProcess.spawn("java", args, {
|
|
13
|
+
stdio: "pipe"
|
|
14
|
+
});
|
|
15
|
+
child.on("error", console.log.bind(console, "child"));
|
|
16
|
+
child.stdin.on("error", console.log.bind(console, "child.stdin"));
|
|
17
|
+
child.stdout.on("error", console.log.bind(console, "child.stdout"));
|
|
18
|
+
child.stderr.on("error", console.log.bind(console, "child.stderr"));
|
|
19
|
+
child.on("exit", (code) => {
|
|
20
|
+
if (code !== 0) {
|
|
21
|
+
return callback && callback(new Error(stderr));
|
|
22
|
+
}
|
|
23
|
+
return callback && callback(null, stdout);
|
|
24
|
+
});
|
|
25
|
+
child.stdout.on("data", (chunk) => {
|
|
26
|
+
stdout += chunk;
|
|
27
|
+
});
|
|
28
|
+
child.stderr.on("data", (chunk) => {
|
|
29
|
+
stderr += chunk;
|
|
30
|
+
});
|
|
31
|
+
child.stdin.end(data);
|
|
32
|
+
};
|
|
33
|
+
var runSync = ({ settings, data, args, callback }) => {
|
|
34
|
+
try {
|
|
35
|
+
const child = childProcess.spawnSync("java", args, {
|
|
36
|
+
input: data,
|
|
37
|
+
stdio: "pipe",
|
|
38
|
+
maxBuffer: settings && settings.buffer
|
|
39
|
+
});
|
|
40
|
+
const stdout = child.stdout.toString();
|
|
41
|
+
const stderr = child.stderr.toString();
|
|
42
|
+
const code = child.status;
|
|
43
|
+
if (code !== 0) {
|
|
44
|
+
return callback && callback(new Error(stderr));
|
|
45
|
+
}
|
|
46
|
+
return callback && callback(null, stdout);
|
|
47
|
+
} catch (err) {
|
|
48
|
+
return callback && callback(err);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
export {
|
|
52
|
+
runCommandLine
|
|
53
|
+
};
|
|
54
|
+
/*!
|
|
55
|
+
* node-minify
|
|
56
|
+
* Copyright(c) 2011-2022 Rodolphe Stoclin
|
|
57
|
+
* MIT Licensed
|
|
58
|
+
*/
|
package/package.json
CHANGED
|
@@ -1,25 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@node-minify/run",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0-beta.0",
|
|
4
4
|
"description": "exec commands for @node-minify",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"compressor",
|
|
7
7
|
"minify",
|
|
8
|
-
"minifier"
|
|
8
|
+
"minifier",
|
|
9
|
+
"run"
|
|
9
10
|
],
|
|
10
11
|
"author": "Rodolphe Stoclin <srodolphe@gmail.com>",
|
|
11
12
|
"homepage": "https://github.com/srod/node-minify/tree/master/packages/run#readme",
|
|
12
13
|
"license": "MIT",
|
|
13
|
-
"main": "lib/run.js",
|
|
14
14
|
"engines": {
|
|
15
15
|
"node": ">=14.0.0"
|
|
16
16
|
},
|
|
17
17
|
"directories": {
|
|
18
|
-
"lib": "
|
|
18
|
+
"lib": "dist",
|
|
19
19
|
"test": "__tests__"
|
|
20
20
|
},
|
|
21
|
+
"main": "./dist/index.js",
|
|
22
|
+
"module": "./dist/index.mjs",
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"exports": {
|
|
25
|
+
"require": "./dist/index.js",
|
|
26
|
+
"import": "./dist/index.mjs",
|
|
27
|
+
"types": "./dist/index.d.ts"
|
|
28
|
+
},
|
|
21
29
|
"files": [
|
|
22
|
-
"
|
|
30
|
+
"dist/**/*"
|
|
23
31
|
],
|
|
24
32
|
"publishConfig": {
|
|
25
33
|
"access": "public"
|
|
@@ -31,5 +39,13 @@
|
|
|
31
39
|
"bugs": {
|
|
32
40
|
"url": "https://github.com/srod/node-minify/issues"
|
|
33
41
|
},
|
|
34
|
-
"
|
|
42
|
+
"scripts": {
|
|
43
|
+
"clean": "pnpm dlx rimraf dist",
|
|
44
|
+
"build": "npm run clean && tsup src/index.ts --format cjs,esm --dts --clean",
|
|
45
|
+
"prepublishOnly": "npm run build"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@node-minify/types": "8.0.0-beta.0"
|
|
49
|
+
},
|
|
50
|
+
"gitHead": "0507c6190577e1939997a8231b07952ba167a780"
|
|
35
51
|
}
|
package/lib/run.js
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.runCommandLine = void 0;
|
|
7
|
-
var _child_process = _interopRequireDefault(require("child_process"));
|
|
8
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
-
/*!
|
|
10
|
-
* node-minify
|
|
11
|
-
* Copyright(c) 2011-2022 Rodolphe Stoclin
|
|
12
|
-
* MIT Licensed
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Module dependencies.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Run the command line with spawn.
|
|
21
|
-
*
|
|
22
|
-
* @param {Array} args
|
|
23
|
-
* @param {String} data
|
|
24
|
-
* @param {Object} settings
|
|
25
|
-
* @param {Function} callback
|
|
26
|
-
*/
|
|
27
|
-
const runCommandLine = ({
|
|
28
|
-
args,
|
|
29
|
-
data,
|
|
30
|
-
settings,
|
|
31
|
-
callback
|
|
32
|
-
}) => {
|
|
33
|
-
if (settings.sync) {
|
|
34
|
-
return runSync({
|
|
35
|
-
settings,
|
|
36
|
-
data,
|
|
37
|
-
args,
|
|
38
|
-
callback
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
return runAsync({
|
|
42
|
-
data,
|
|
43
|
-
args,
|
|
44
|
-
callback
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Exec command as async.
|
|
50
|
-
*
|
|
51
|
-
* @param {String} data
|
|
52
|
-
* @param {Array} args
|
|
53
|
-
* @param {Function} callback
|
|
54
|
-
*/
|
|
55
|
-
exports.runCommandLine = runCommandLine;
|
|
56
|
-
const runAsync = ({
|
|
57
|
-
data,
|
|
58
|
-
args,
|
|
59
|
-
callback
|
|
60
|
-
}) => {
|
|
61
|
-
let stdout = '';
|
|
62
|
-
let stderr = '';
|
|
63
|
-
const child = _child_process.default.spawn('java', args, {
|
|
64
|
-
stdio: 'pipe'
|
|
65
|
-
});
|
|
66
|
-
child.on('error', console.log.bind(console, 'child'));
|
|
67
|
-
child.stdin.on('error', console.log.bind(console, 'child.stdin'));
|
|
68
|
-
child.stdout.on('error', console.log.bind(console, 'child.stdout'));
|
|
69
|
-
child.stderr.on('error', console.log.bind(console, 'child.stderr'));
|
|
70
|
-
child.on('exit', code => {
|
|
71
|
-
if (code !== 0) {
|
|
72
|
-
return callback(new Error(stderr));
|
|
73
|
-
}
|
|
74
|
-
return callback(null, stdout);
|
|
75
|
-
});
|
|
76
|
-
child.stdout.on('data', chunk => {
|
|
77
|
-
stdout += chunk;
|
|
78
|
-
});
|
|
79
|
-
child.stderr.on('data', chunk => {
|
|
80
|
-
stderr += chunk;
|
|
81
|
-
});
|
|
82
|
-
child.stdin.end(data);
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Exec command as sync.
|
|
87
|
-
*
|
|
88
|
-
* @param {Object} settings
|
|
89
|
-
* @param {String} data
|
|
90
|
-
* @param {Array} args
|
|
91
|
-
* @param {Function} callback
|
|
92
|
-
*/
|
|
93
|
-
const runSync = ({
|
|
94
|
-
settings,
|
|
95
|
-
data,
|
|
96
|
-
args,
|
|
97
|
-
callback
|
|
98
|
-
}) => {
|
|
99
|
-
try {
|
|
100
|
-
const child = _child_process.default.spawnSync('java', args, {
|
|
101
|
-
input: data,
|
|
102
|
-
stdio: 'pipe',
|
|
103
|
-
maxBuffer: settings.buffer
|
|
104
|
-
});
|
|
105
|
-
const stdout = child.stdout.toString();
|
|
106
|
-
const stderr = child.stderr.toString();
|
|
107
|
-
const code = child.status;
|
|
108
|
-
if (code !== 0) {
|
|
109
|
-
return callback(new Error(stderr));
|
|
110
|
-
}
|
|
111
|
-
return callback(null, stdout);
|
|
112
|
-
} catch (err) {
|
|
113
|
-
return callback(err);
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Expose `runCommandLine()`.
|
|
119
|
-
*/
|