@tryghost/ghst 0.4.2 → 0.4.3

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 CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/index.ts
4
- import { pathToFileURL } from "url";
4
+ import { realpathSync } from "fs";
5
+ import { fileURLToPath, pathToFileURL } from "url";
5
6
  import { Command, CommanderError } from "commander";
6
7
 
7
8
  // src/commands/api.ts
@@ -8922,18 +8923,25 @@ async function main(argv) {
8922
8923
  const exitCode = await run(argv);
8923
8924
  process.exit(exitCode);
8924
8925
  }
8925
- function isMainModule() {
8926
- const entry = process.argv[1];
8926
+ function isMainModule(moduleUrl = import.meta.url, argvEntry = process.argv[1]) {
8927
+ const entry = argvEntry;
8927
8928
  if (!entry) {
8928
8929
  return false;
8929
8930
  }
8930
- return import.meta.url === pathToFileURL(entry).href;
8931
+ try {
8932
+ const modulePath = realpathSync(fileURLToPath(moduleUrl));
8933
+ const entryPath = realpathSync(entry);
8934
+ return modulePath === entryPath;
8935
+ } catch {
8936
+ return moduleUrl === pathToFileURL(entry).href;
8937
+ }
8931
8938
  }
8932
8939
  if (isMainModule()) {
8933
8940
  void main(process.argv);
8934
8941
  }
8935
8942
  export {
8936
8943
  buildProgram,
8944
+ isMainModule,
8937
8945
  main,
8938
8946
  run
8939
8947
  };