@0x-jerry/x 2.12.3 → 2.12.4
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/{chunk-BB5TC3CY.js → chunk-MLK4NZGK.js} +1 -1
- package/dist/x.js +1 -1
- package/dist/xn.js +1 -1
- package/dist/xr.js +35 -22
- package/package.json +1 -1
package/dist/x.js
CHANGED
package/dist/xn.js
CHANGED
package/dist/xr.js
CHANGED
|
@@ -4,13 +4,10 @@ import {
|
|
|
4
4
|
} from "./chunk-ELIYGHQS.js";
|
|
5
5
|
import {
|
|
6
6
|
version
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-MLK4NZGK.js";
|
|
8
8
|
|
|
9
9
|
// src/xr.ts
|
|
10
10
|
import { sliver } from "@0x-jerry/silver";
|
|
11
|
-
import { readdir } from "fs/promises";
|
|
12
|
-
import { pathExists as pathExists4 } from "fs-extra/esm";
|
|
13
|
-
import path5 from "path";
|
|
14
11
|
|
|
15
12
|
// src/commands/run.ts
|
|
16
13
|
import path4 from "path";
|
|
@@ -44,9 +41,9 @@ var DenoTaskDetecter = class {
|
|
|
44
41
|
};
|
|
45
42
|
|
|
46
43
|
// src/commands/run/node.ts
|
|
47
|
-
import { readFile as readFile2 } from "fs/promises";
|
|
44
|
+
import { readdir, readFile as readFile2 } from "fs/promises";
|
|
48
45
|
import path2 from "path";
|
|
49
|
-
import { pathExists as pathExists2 } from "fs-extra";
|
|
46
|
+
import { pathExists as pathExists2 } from "fs-extra/esm";
|
|
50
47
|
var NodeTaskDetecter = class {
|
|
51
48
|
async binaryPaths(cwd) {
|
|
52
49
|
const envPaths = [];
|
|
@@ -74,6 +71,21 @@ var NodeTaskDetecter = class {
|
|
|
74
71
|
return tasks;
|
|
75
72
|
}
|
|
76
73
|
};
|
|
74
|
+
async function getBinariesPairs() {
|
|
75
|
+
let dir = process.cwd();
|
|
76
|
+
const binaries = {};
|
|
77
|
+
do {
|
|
78
|
+
const binPath = path2.join(dir, "node_modules", ".bin");
|
|
79
|
+
if (await pathExists2(binPath)) {
|
|
80
|
+
const files = await readdir(binPath);
|
|
81
|
+
for (const filename of files) {
|
|
82
|
+
binaries[filename] = path2.join(binPath, filename);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
dir = path2.resolve(dir, "..");
|
|
86
|
+
} while (dir !== path2.resolve(dir, ".."));
|
|
87
|
+
return binaries;
|
|
88
|
+
}
|
|
77
89
|
|
|
78
90
|
// src/commands/run/rust.ts
|
|
79
91
|
import path3 from "path";
|
|
@@ -105,14 +117,29 @@ async function runScript(command, params = []) {
|
|
|
105
117
|
}
|
|
106
118
|
}
|
|
107
119
|
}
|
|
120
|
+
if (await runAsBinary(command, params)) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
108
123
|
const allScripts = await getAvailableCommands();
|
|
109
124
|
console.log(
|
|
110
125
|
pc.red("["),
|
|
111
126
|
pc.cyan(`${command}`),
|
|
112
|
-
pc.red("] not exists in the list: "),
|
|
127
|
+
pc.red("] does not exists in the list: "),
|
|
113
128
|
allScripts.map((name) => pc.cyan(name)).join(", ")
|
|
114
129
|
);
|
|
115
130
|
}
|
|
131
|
+
async function runAsBinary(command, params) {
|
|
132
|
+
const cwd = process.cwd();
|
|
133
|
+
const binariesPair = await getBinariesPairs();
|
|
134
|
+
const binaries = Object.keys(binariesPair);
|
|
135
|
+
if (binaries.includes(command)) {
|
|
136
|
+
const binPaths = await new NodeTaskDetecter().binaryPaths(cwd);
|
|
137
|
+
const env = makeEnv(binPaths || []);
|
|
138
|
+
await exec(command, params, { env });
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
116
143
|
function makeEnv(extraPaths) {
|
|
117
144
|
const env = process.env;
|
|
118
145
|
const envPaths = process.env.PATH?.split(path4.delimiter) || [];
|
|
@@ -143,21 +170,7 @@ ins.type("scripts", async () => {
|
|
|
143
170
|
const allScripts = await getAvailableCommands();
|
|
144
171
|
return allScripts;
|
|
145
172
|
});
|
|
146
|
-
ins.type("bin",
|
|
147
|
-
let dir = process.cwd();
|
|
148
|
-
const binaries = [];
|
|
149
|
-
do {
|
|
150
|
-
const binPath = path5.join(dir, "node_modules", ".bin");
|
|
151
|
-
if (await pathExists4(binPath)) {
|
|
152
|
-
const files = await readdir(binPath);
|
|
153
|
-
for (const filename of files) {
|
|
154
|
-
binaries.push(filename);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
dir = path5.resolve(dir, "..");
|
|
158
|
-
} while (dir !== path5.resolve(dir, ".."));
|
|
159
|
-
return binaries;
|
|
160
|
-
});
|
|
173
|
+
ins.type("bin", () => getBinariesPairs().then((resp) => Object.keys(resp)));
|
|
161
174
|
async function defaultAction(_, arg) {
|
|
162
175
|
const [commandOrFile, ...params] = arg._;
|
|
163
176
|
try {
|