novel-writer-cli 0.0.1 → 0.0.2

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/cli.js +20 -2
  2. package/package.json +2 -1
package/dist/cli.js CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import { Command, CommanderError } from "commander";
3
+ import { realpathSync } from "node:fs";
3
4
  import { resolve } from "node:path";
4
- import { pathToFileURL } from "node:url";
5
+ import { fileURLToPath, pathToFileURL } from "node:url";
5
6
  import { buildCharacterVoiceProfiles, clearCharacterVoiceDriftFile, computeCharacterVoiceDrift, loadActiveCharacterVoiceDriftIds, loadCharacterVoiceProfiles, writeCharacterVoiceDriftFile, writeCharacterVoiceProfilesFile } from "./character-voice.js";
6
7
  import { NovelCliError } from "./errors.js";
7
8
  import { errJson, okJson, printJson } from "./output.js";
@@ -550,7 +551,24 @@ export async function main(argv = process.argv.slice(2)) {
550
551
  }
551
552
  }
552
553
  const entryPath = process.argv[1] ? resolve(process.argv[1]) : null;
553
- if (entryPath && import.meta.url === pathToFileURL(entryPath).href) {
554
+ const selfPath = fileURLToPath(import.meta.url);
555
+ const safeRealpath = (p) => {
556
+ try {
557
+ return realpathSync(p);
558
+ }
559
+ catch {
560
+ return null;
561
+ }
562
+ };
563
+ const entryUrl = entryPath ? pathToFileURL(entryPath).href : null;
564
+ const isEntrypoint = entryPath !== null &&
565
+ (entryUrl === import.meta.url ||
566
+ (() => {
567
+ const a = safeRealpath(entryPath);
568
+ const b = safeRealpath(selfPath);
569
+ return a !== null && b !== null && a === b;
570
+ })());
571
+ if (isEntrypoint) {
554
572
  main()
555
573
  .then((code) => {
556
574
  process.exitCode = code;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "novel-writer-cli",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Executor-agnostic novel orchestration CLI",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -30,6 +30,7 @@
30
30
  "scripts": {
31
31
  "dev": "tsx src/cli.ts",
32
32
  "build": "tsc -p tsconfig.json",
33
+ "prepack": "npm run build",
33
34
  "start": "node dist/cli.js",
34
35
  "typecheck": "tsc -p tsconfig.json --noEmit",
35
36
  "test": "npm run build && node --test dist/__tests__/*.test.js"