@tsed/cli 7.5.0-rc.6 → 7.5.0-rc.8
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.
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
2
4
|
import process from "node:process";
|
|
3
5
|
import { fileURLToPath } from "node:url";
|
|
4
6
|
function runNode(cmd, args) {
|
|
@@ -17,7 +19,25 @@ function runNode(cmd, args) {
|
|
|
17
19
|
});
|
|
18
20
|
});
|
|
19
21
|
}
|
|
22
|
+
function toPath(value) {
|
|
23
|
+
if (value.startsWith("file://")) {
|
|
24
|
+
return fileURLToPath(value);
|
|
25
|
+
}
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
export async function resolveViteBinFromPackageJsonPath(packageJsonPath) {
|
|
29
|
+
const packageJson = JSON.parse(await readFile(packageJsonPath, "utf-8"));
|
|
30
|
+
const binRelativePath = typeof packageJson.bin === "string" ? packageJson.bin : packageJson.bin?.vite;
|
|
31
|
+
if (!binRelativePath) {
|
|
32
|
+
throw new Error("Unable to resolve Vite CLI binary from vite/package.json");
|
|
33
|
+
}
|
|
34
|
+
return path.resolve(path.dirname(packageJsonPath), binRelativePath);
|
|
35
|
+
}
|
|
36
|
+
export async function resolveViteBin() {
|
|
37
|
+
const packageJsonPath = toPath(await import.meta.resolve("vite/package.json"));
|
|
38
|
+
return resolveViteBinFromPackageJsonPath(packageJsonPath);
|
|
39
|
+
}
|
|
20
40
|
export async function build(rawArgs = process.argv.slice(2)) {
|
|
21
|
-
const viteBin =
|
|
41
|
+
const viteBin = await resolveViteBin();
|
|
22
42
|
await runNode(process.execPath, [viteBin, "build", ...rawArgs]);
|
|
23
43
|
}
|