supacloud 0.3.0 → 0.4.0
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/index.js +8 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
4
|
import { spawn } from "node:child_process";
|
|
5
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
5
|
+
import { existsSync, readFileSync, realpathSync } from "node:fs";
|
|
6
6
|
import { createRequire } from "node:module";
|
|
7
7
|
import { dirname, join, parse } from "node:path";
|
|
8
8
|
import { fileURLToPath } from "node:url";
|
|
@@ -221,14 +221,16 @@ async function run(args) {
|
|
|
221
221
|
process.exit(1);
|
|
222
222
|
});
|
|
223
223
|
}
|
|
224
|
-
|
|
224
|
+
function isMainModule(moduleUrl, argvEntry = process.argv[1]) {
|
|
225
|
+
if (!argvEntry)
|
|
226
|
+
return false;
|
|
225
227
|
try {
|
|
226
|
-
return fileURLToPath(
|
|
228
|
+
return realpathSync(fileURLToPath(moduleUrl)) === realpathSync(argvEntry);
|
|
227
229
|
} catch {
|
|
228
230
|
return false;
|
|
229
231
|
}
|
|
230
|
-
}
|
|
231
|
-
if (
|
|
232
|
+
}
|
|
233
|
+
if (isMainModule(import.meta.url)) {
|
|
232
234
|
run(process.argv.slice(2)).catch((err) => {
|
|
233
235
|
const message = err instanceof Error ? err.message : String(err);
|
|
234
236
|
console.error(`❌ supacloud 启动失败: ${message}`);
|
|
@@ -239,6 +241,7 @@ export {
|
|
|
239
241
|
resolveSubpackageEntry,
|
|
240
242
|
resolveInstalledPackage,
|
|
241
243
|
isNewerVersion,
|
|
244
|
+
isMainModule,
|
|
242
245
|
isAutoUpdateDisabled,
|
|
243
246
|
getNpmRegistry,
|
|
244
247
|
fetchLatestVersion,
|