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.
Files changed (2) hide show
  1. package/dist/index.js +8 -5
  2. 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
- var isMainEntry = (() => {
224
+ function isMainModule(moduleUrl, argvEntry = process.argv[1]) {
225
+ if (!argvEntry)
226
+ return false;
225
227
  try {
226
- return fileURLToPath(import.meta.url) === process.argv[1];
228
+ return realpathSync(fileURLToPath(moduleUrl)) === realpathSync(argvEntry);
227
229
  } catch {
228
230
  return false;
229
231
  }
230
- })();
231
- if (isMainEntry) {
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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "supacloud",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Unified entrypoint: `supacloud cli` and `supacloud admin` in one command",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",