@cldmv/fix-headers 1.1.0 → 1.1.1

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/package.json +1 -1
  2. package/src/cli.mjs +12 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cldmv/fix-headers",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Multi-language project header normalizer with auto-detection and override support.",
5
5
  "type": "module",
6
6
  "main": "./index.cjs",
package/src/cli.mjs CHANGED
@@ -13,8 +13,9 @@
13
13
  */
14
14
 
15
15
  import { readFile } from "node:fs/promises";
16
+ import { realpathSync } from "node:fs";
16
17
  import { isAbsolute, join } from "node:path";
17
- import { pathToFileURL } from "node:url";
18
+ import { fileURLToPath, pathToFileURL } from "node:url";
18
19
  import fixHeaders from "./fix-header.mjs";
19
20
 
20
21
  /**
@@ -293,7 +294,16 @@ export async function runCli(argv, deps = {}) {
293
294
  * @returns {boolean} Whether the entrypoint branch was executed.
294
295
  */
295
296
  export function runCliAsMain(argv = process.argv, moduleUrl = import.meta.url, executor = runCli) {
296
- const isMain = argv[1] && moduleUrl === pathToFileURL(argv[1]).href;
297
+ let isMain = false;
298
+ if (argv[1]) {
299
+ try {
300
+ const argvRealPath = realpathSync(argv[1]);
301
+ const moduleRealPath = realpathSync(fileURLToPath(moduleUrl));
302
+ isMain = argvRealPath === moduleRealPath;
303
+ } catch {
304
+ isMain = moduleUrl === pathToFileURL(argv[1]).href;
305
+ }
306
+ }
297
307
  if (!isMain) {
298
308
  return false;
299
309
  }