numux 2.6.0 → 2.6.1
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/numux.js +28 -10
- package/package.json +1 -1
package/dist/numux.js
CHANGED
|
@@ -36,7 +36,7 @@ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports,
|
|
|
36
36
|
var require_package = __commonJS((exports, module) => {
|
|
37
37
|
module.exports = {
|
|
38
38
|
name: "numux",
|
|
39
|
-
version: "2.6.
|
|
39
|
+
version: "2.6.1",
|
|
40
40
|
description: "Terminal multiplexer with dependency orchestration",
|
|
41
41
|
type: "module",
|
|
42
42
|
license: "MIT",
|
|
@@ -713,29 +713,47 @@ function splitPatternArgs(raw) {
|
|
|
713
713
|
return { glob: raw, extraArgs: "" };
|
|
714
714
|
return { glob: raw.slice(0, i), extraArgs: raw.slice(i) };
|
|
715
715
|
}
|
|
716
|
+
function expandScriptCommand(raw, pm) {
|
|
717
|
+
const { glob: script, extraArgs } = splitPatternArgs(raw);
|
|
718
|
+
if (extraArgs) {
|
|
719
|
+
return `${pm} run ${script} --${extraArgs}`;
|
|
720
|
+
}
|
|
721
|
+
return `${pm} run ${script}`;
|
|
722
|
+
}
|
|
716
723
|
function expandScriptPatterns(config, cwd) {
|
|
717
724
|
const entries = Object.entries(config.processes);
|
|
725
|
+
const cmd = (v) => typeof v === "string" ? v : v?.command;
|
|
718
726
|
const hasScriptRef = entries.some(([name, value]) => isScriptReference(name, value));
|
|
719
|
-
|
|
727
|
+
const hasNpmCommand = entries.some(([, v]) => {
|
|
728
|
+
const c = cmd(v);
|
|
729
|
+
return typeof c === "string" && c.startsWith("npm:");
|
|
730
|
+
});
|
|
731
|
+
if (!(hasScriptRef || hasNpmCommand))
|
|
720
732
|
return config;
|
|
721
733
|
const dir = config.cwd ?? cwd ?? process.cwd();
|
|
722
734
|
const pkgPath = resolve(dir, "package.json");
|
|
723
|
-
if (!existsSync(pkgPath)) {
|
|
735
|
+
if (!existsSync(pkgPath) && hasScriptRef) {
|
|
724
736
|
throw new Error(`Wildcard patterns require a package.json (looked in ${dir})`);
|
|
725
737
|
}
|
|
726
|
-
const pkgJson = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
738
|
+
const pkgJson = existsSync(pkgPath) ? JSON.parse(readFileSync(pkgPath, "utf-8")) : {};
|
|
727
739
|
const scripts = pkgJson.scripts;
|
|
728
|
-
|
|
729
|
-
throw new Error('package.json has no "scripts" field');
|
|
730
|
-
}
|
|
731
|
-
const scriptNames = Object.keys(scripts);
|
|
740
|
+
const scriptNames = scripts && typeof scripts === "object" ? Object.keys(scripts) : [];
|
|
732
741
|
const pm = detectPackageManager(pkgJson, dir);
|
|
733
742
|
const expanded = {};
|
|
734
743
|
for (const [name, value] of entries) {
|
|
735
744
|
if (!isScriptReference(name, value)) {
|
|
736
|
-
|
|
745
|
+
let proc = value;
|
|
746
|
+
const c = cmd(proc);
|
|
747
|
+
if (typeof c === "string" && c.startsWith("npm:")) {
|
|
748
|
+
const expandedCmd = expandScriptCommand(c.slice(4), pm);
|
|
749
|
+
proc = typeof proc === "string" ? expandedCmd : { ...proc, command: expandedCmd };
|
|
750
|
+
}
|
|
751
|
+
expanded[name] = proc;
|
|
737
752
|
continue;
|
|
738
753
|
}
|
|
754
|
+
if (!scripts || typeof scripts !== "object") {
|
|
755
|
+
throw new Error('package.json has no "scripts" field');
|
|
756
|
+
}
|
|
739
757
|
const rawPattern = name.startsWith("npm:") ? name.slice(4) : name;
|
|
740
758
|
const { glob: globPattern, extraArgs } = splitPatternArgs(rawPattern);
|
|
741
759
|
const template = value ?? {};
|
|
@@ -762,7 +780,7 @@ function expandScriptPatterns(config, cwd) {
|
|
|
762
780
|
const { color: _color, ...rest } = template;
|
|
763
781
|
expanded[displayName] = {
|
|
764
782
|
...rest,
|
|
765
|
-
command: `${
|
|
783
|
+
command: expandScriptCommand(`${scriptName}${extraArgs}`, pm),
|
|
766
784
|
...color ? { color } : {}
|
|
767
785
|
};
|
|
768
786
|
}
|