Lines 1-56javascript
3 * npm launcher: exec the platform optionalDependency binary when installed,
4 * otherwise fall back to the bundled CJS entry (monorepo / unpublished layouts).
6import { spawnSync } from 'node:child_process';
7import { createRequire } from 'node:module';
HighChild Process
Package source references child process execution.
bin/skillet.jsView on unpkg · L5 8import { existsSync } from 'node:fs';
9import { dirname, join } from 'node:path';
10import { fileURLToPath } from 'node:url';
12const require = createRequire(import.meta.url);
13const pkgRoot = join(dirname(fileURLToPath(import.meta.url)), '..');
15/** @type {Record<string, string>} */
16const PLATFORM_PACKAGES = {
17 'darwin-arm64': '@skilletmd/cli-darwin-arm64',
18 'darwin-x64': '@skilletmd/cli-darwin-x64',
19 'linux-x64': '@skilletmd/cli-linux-x64',
20 'linux-arm64': '@skilletmd/cli-linux-arm64',
21 'win32-x64': '@skilletmd/cli-win32-x64',
24function resolveNativeBinary() {
25 const pkgName = PLATFORM_PACKAGES[`${process.platform}-${process.arch}`];
26 if (!pkgName) return null;
28 const pkgJson = require.resolve(`${pkgName}/package.json`);
29 const binName = process.platform === 'win32' ? 'skillet.exe' : 'skillet';
HighCross File Remote Execution Context
Source spawns a local helper that also contains network and dynamic execution context; review data flow before blocking.
bin/skillet.jsView on unpkg · L5 30 const candidate = join(dirname(pkgJson), 'bin', binName);
31 return existsSync(candidate) ? candidate : null;
37function execAndExit(command, args) {
38 const result = spawnSync(command, args, { stdio: 'inherit' });
40 console.error(result.error.message);
43 process.exit(result.status ?? 1);
46const native = resolveNativeBinary();
48 execAndExit(native, process.argv.slice(2));
51const cjs = join(pkgRoot, 'dist', 'cli.cjs');
52if (!existsSync(cjs)) {
54 'Skillet CLI: no native binary for this platform and dist/cli.cjs is missing. Run `pnpm bundle` in the monorepo or reinstall @skilletmd/cli.',