@lsky/tools
Advanced tools
| "use strict"; | ||
| exports.__esModule = true; | ||
| exports.exec = void 0; | ||
| var _child_process = require("child_process"); | ||
| function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
| var exec = function exec(_ref) { | ||
| var _ref$command = _ref.command, | ||
| command = _ref$command === void 0 ? "" : _ref$command, | ||
| _ref$args = _ref.args, | ||
| args = _ref$args === void 0 ? [] : _ref$args, | ||
| _ref$option = _ref.option, | ||
| option = _ref$option === void 0 ? [] : _ref$option, | ||
| log = _ref.log; | ||
| return new Promise(function (resolve, reject) { | ||
| if (!command || args.length <= 0) { | ||
| console.log(); | ||
| console.log(); | ||
| reject("参数不全,无法执行spawn命令..."); | ||
| process.exit(1); | ||
| } | ||
| log && log("\u6267\u884C\u547D\u4EE4\uFF1A" + command); | ||
| var child = (0, _child_process.spawn)(command, args, _extends({}, option)); | ||
| var rs = ""; | ||
| child.stdout && child.stdout.on("data", function (msg) { | ||
| rs += msg; | ||
| }); | ||
| child.on("error", function (err) { | ||
| reject(err); | ||
| }); | ||
| child.on("close", function (code) { | ||
| if (code !== 0) { | ||
| reject("程序执行出错,请重新执行。"); | ||
| return; | ||
| } | ||
| resolve(rs); | ||
| }); | ||
| }); | ||
| }; | ||
| exports.exec = exec; |
+4
-1
| { | ||
| "name": "@lsky/tools", | ||
| "version": "1.0.1", | ||
| "version": "1.0.2", | ||
| "main": "lib/index.js", | ||
@@ -14,2 +14,5 @@ "repository": "git@github.com:lsky-walt/tools.git", | ||
| }, | ||
| "publishConfig": { | ||
| "registry": "https://registry.npmjs.org/" | ||
| }, | ||
| "files": [ | ||
@@ -16,0 +19,0 @@ "lib", |
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
30728
5.36%15
7.14%570
7.34%1
Infinity%