log-llm-config 1.3.18 → 1.3.19

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.
@@ -0,0 +1,28 @@
1
+ import { basename } from 'node:path';
2
+ import { fileURLToPath } from 'node:url';
3
+ function toFsPath(scriptPathOrFileUrl) {
4
+ if (scriptPathOrFileUrl.startsWith('file://')) {
5
+ return fileURLToPath(scriptPathOrFileUrl);
6
+ }
7
+ return scriptPathOrFileUrl;
8
+ }
9
+ /**
10
+ * Basename of the invoked script, normalized so npm `bin` names (hyphens) match compiled
11
+ * artifacts (underscores), e.g. `execute-trusted-restarts` → `execute_trusted_restarts`.
12
+ */
13
+ export function normalizedCliScriptBasename(scriptPathOrFileUrl) {
14
+ return basename(toFsPath(scriptPathOrFileUrl))
15
+ .replace(/\.[cm]?js$/, '')
16
+ .replace(/-/g, '_');
17
+ }
18
+ /**
19
+ * True when this process was started as the given module's CLI entrypoint.
20
+ * Handles npx bin shims (symlink paths) and hyphen vs underscore bin/file naming.
21
+ */
22
+ export function isThisCliModule(argv1, thisImportMetaUrl) {
23
+ if (!argv1)
24
+ return false;
25
+ const entry = normalizedCliScriptBasename(argv1);
26
+ const self = normalizedCliScriptBasename(thisImportMetaUrl);
27
+ return entry !== '' && entry === self;
28
+ }
@@ -4,21 +4,9 @@
4
4
  * stderr stays quiet; failures logged via hookRunLog.
5
5
  */
6
6
  import { readFileSync } from 'node:fs';
7
- import { pathToFileURL } from 'node:url';
8
- import { resolve } from 'node:path';
7
+ import { isThisCliModule } from './cli_invocation_match.js';
9
8
  import { hookRunLog } from './log_config_files/runtime/hook_logger.js';
10
9
  import { executeTrustedRestartCommands } from './log_config_files/runtime/trusted_restarts.js';
11
- function isRunAsCliModule() {
12
- const entry = process.argv[1];
13
- if (!entry)
14
- return false;
15
- try {
16
- return import.meta.url === pathToFileURL(resolve(entry)).href;
17
- }
18
- catch {
19
- return false;
20
- }
21
- }
22
10
  function main() {
23
11
  let raw;
24
12
  try {
@@ -45,7 +33,7 @@ function main() {
45
33
  const strings = cmds.filter((c) => typeof c === 'string');
46
34
  executeTrustedRestartCommands(strings);
47
35
  }
48
- if (isRunAsCliModule()) {
36
+ if (isThisCliModule(process.argv[1], import.meta.url)) {
49
37
  try {
50
38
  main();
51
39
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "log-llm-config",
3
- "version": "1.3.18",
3
+ "version": "1.3.19",
4
4
  "description": "CLI helpers for logging hardware UUIDs and posting startup payloads to Optimus Security.",
5
5
  "type": "module",
6
6
  "bin": {