isNpxInvocation (src/command-install.ts)

editor · packages/cli/src/command-install.ts · typescript · MIT
cli, tag:knn-classified

CLI helpers to detect npx and install global Pascal command.

// Source: https://github.com/pascalorg/editor | License: MIT | Copyright 2026 Pascal Group Inc
// Provided via justclaw.it.com; keep this notice with the code.
import { spawn } from 'node:child_process'

const INSTALL_TIMEOUT_MS = 2 * 60_000

export function isNpxInvocation(environment: NodeJS.ProcessEnv = process.env): boolean {
  return (
    environment.npm_lifecycle_event === 'npx' ||
    (environment.npm_command === 'exec' &&
      (environment.PATH ?? '').split(':').some((entry) => entry.includes('/_npx/')))
  )
}

export async function installGlobalPascalCommand(
  packageVersion: string,
  runInstaller: Installer = runNpmInstaller,
): Promise<boolean> {
  const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm'
  return (
    (await runInstaller(npm, [
      'install',
      '

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key