-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathcli-dispatch.mts
More file actions
executable file
·39 lines (31 loc) · 1.28 KB
/
Copy pathcli-dispatch.mts
File metadata and controls
executable file
·39 lines (31 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { getInvocationMode } from './util/cli/invocation-mode.mts'
import { errorMessage } from '@socketsecurity/lib-stable/errors/message'
import { getDefaultLogger } from '@socketsecurity/lib-stable/logger/default'
import { isMainModule } from '../scripts/fleet/process/is-main-module.mts'
import { runMain } from '../scripts/fleet/process/run-main.mts'
import type { ScriptMeta } from '../scripts/fleet/process/run-main.mts'
const logger = getDefaultLogger()
const SCRIPT_META: ScriptMeta = {
describe: 'dispatch a Socket CLI wrapper invocation to its command mode',
help: 'Usage: pnpm run dev [arguments]',
json: 'native',
}
export function runCliProduct(): void {
void main().catch(error => {
logger.error(errorMessage(error))
process.exitCode = 1
})
}
// Route to the appropriate CLI based on invocation mode.
export async function main(): Promise<void> {
const mode = getInvocationMode()
// Set environment variable for child processes.
process.env['SOCKET_CLI_MODE'] = mode
// Import and run the appropriate CLI function.
// All wrapper modes now route through the main CLI entry with the mode set.
// The CLI will detect the mode and run the appropriate command.
await import('./cli-entry.mjs')
}
if (isMainModule(import.meta.url)) {
runMain(main, SCRIPT_META)
}