utiller 1.0.386 → 1.0.387
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.
|
@@ -58,27 +58,43 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
58
58
|
return reg.test(item.fileNameExtension);
|
|
59
59
|
}].concat(exclude));
|
|
60
60
|
});
|
|
61
|
+
// 💡 調整函式簽名以接收可選的執行路徑 (path/cwd)
|
|
61
62
|
(0, _defineProperty2["default"])(_this, "executeCommandLine", /*#__PURE__*/function () {
|
|
62
63
|
var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(command) {
|
|
63
|
-
var
|
|
64
|
+
var executionPath,
|
|
65
|
+
self,
|
|
66
|
+
_args = arguments;
|
|
64
67
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
65
68
|
while (1) switch (_context.prev = _context.next) {
|
|
66
69
|
case 0:
|
|
67
|
-
|
|
68
|
-
_this
|
|
70
|
+
executionPath = _args.length > 1 && _args[1] !== undefined ? _args[1] : process.cwd();
|
|
71
|
+
self = _this; // 輸出時顯示執行的目錄,增加可讀性
|
|
72
|
+
_this.appendInfo("\u57F7\u884C\u8173\u672C: ".concat(command));
|
|
73
|
+
_this.appendInfo("\u57F7\u884C\u8DEF\u5F91: ".concat(executionPath));
|
|
69
74
|
return _context.abrupt("return", new Promise(function (resolve, reject) {
|
|
70
|
-
|
|
75
|
+
// 核心改動:將執行路徑作為 options 物件的 cwd 屬性傳遞
|
|
76
|
+
_child_process["default"].exec(command, {
|
|
77
|
+
cwd: executionPath
|
|
78
|
+
},
|
|
79
|
+
// ⬅️ 新增的 options 物件,指定 cwd
|
|
80
|
+
function (error, stdout, stderr) {
|
|
71
81
|
self.appendInfo("".concat(stdout));
|
|
72
82
|
self.appendInfo("".concat(stderr));
|
|
73
83
|
if (error) {
|
|
74
84
|
self.appendError("\u57F7\u884C\u932F\u8AA4: ".concat(error));
|
|
75
|
-
|
|
85
|
+
|
|
86
|
+
// 🚨 重要的錯誤處理:將 stderr 包含在拒絕訊息中,便於除錯
|
|
87
|
+
var fullError = new Error("Command failed: ".concat(error.message));
|
|
88
|
+
fullError.code = error.code;
|
|
89
|
+
fullError.stdout = stdout;
|
|
90
|
+
fullError.stderr = stderr;
|
|
91
|
+
reject(fullError);
|
|
76
92
|
return;
|
|
77
93
|
}
|
|
78
94
|
resolve(stdout.trim());
|
|
79
95
|
});
|
|
80
96
|
}));
|
|
81
|
-
case
|
|
97
|
+
case 5:
|
|
82
98
|
case "end":
|
|
83
99
|
return _context.stop();
|
|
84
100
|
}
|
|
@@ -1129,7 +1145,7 @@ var NodeUtiller = /*#__PURE__*/function (_Utiller) {
|
|
|
1129
1145
|
release = _this7.persistByPath(_path4["default"].join(path, "release"));
|
|
1130
1146
|
/** 利用babel 產生出 es5相容性高的src file */
|
|
1131
1147
|
_context13.next = 8;
|
|
1132
|
-
return _this7.executeCommandLine("
|
|
1148
|
+
return _this7.executeCommandLine("npx babel ./temp --out-dir ./release/lib", path);
|
|
1133
1149
|
case 8:
|
|
1134
1150
|
pathOfPackageJson = _path4["default"].join(path, "package.json");
|
|
1135
1151
|
_context13.prev = 9;
|
package/package.json
CHANGED