How to use @ionic/utils-terminal - 6 common examples

To help you get started, we’ve selected a few @ionic/utils-terminal examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ionic-team / ionic-cli / packages / ionic / src / lib / shell.ts View on Github external
async resolveCommandPath(command: string, options: SpawnOptions): Promise {
    if (TERMINAL_INFO.windows) {
      try {
        return await this.which(command, { PATH: options.env && options.env.PATH ? options.env.PATH : process.env.PATH });
      } catch (e) {
        // ignore
      }
    }

    return command;
  }
github ionic-team / ionic-cli / packages / ionic / src / lib / index.ts View on Github external
export async function generateIonicEnvironment(ctx: IonicContext, pargv: string[]): Promise<{ env: IonicEnvironment; project?: IProject; }> {
  process.chdir(ctx.execPath);

  const argv = parseGlobalOptions(pargv);
  const config = new Config(path.resolve(process.env['IONIC_CONFIG_DIRECTORY'] || DEFAULT_CONFIG_DIRECTORY, CONFIG_FILE));

  debug('Terminal info: %o', TERMINAL_INFO);

  if (config.get('interactive') === false || !TERMINAL_INFO.tty || TERMINAL_INFO.ci) {
    argv['interactive'] = false;
  }

  const flags = argv as any as IonicEnvironmentFlags; // TODO
  debug('CLI global options: %o', flags);

  const log = new Logger({
    level: argv['quiet'] ? LOGGER_LEVELS.WARN : LOGGER_LEVELS.INFO,
    handlers: createDefaultLoggerHandlers(),
  });

  const prompt = await createPromptModule({
    interactive: argv['interactive'],
    onFallback: createOnFallback({ flags, log }),
  });
github ionic-team / ionic-cli / packages / ionic / src / lib / command.ts View on Github external
const telemetryPromise = (async () => {
      if (this.env.config.get('telemetry') !== false && !TERMINAL_INFO.ci && TERMINAL_INFO.tty) {
        const { Telemetry } = await import('./telemetry');

        let cmdInputs: CommandLineInputs = [];
        const metadata = await this.getMetadata();

        if (metadata.name === 'login' || metadata.name === 'logout') {
          // This is a hack to wait until the selected commands complete before
          // sending telemetry data. These commands update `this.env` in some
          // way, which is used in the `Telemetry` instance.
          await runPromise;
        } else if (metadata.name === 'completion') {
          // Ignore telemetry for these commands.
          return;
        } else if (metadata.name === 'help') {
          cmdInputs = inputs;
        } else {
github ionic-team / ionic-cli / packages / @ionic / utils-subprocess / src / index.ts View on Github external
}

export function spawn(command: string, args: readonly string[] = [], options?: SpawnOptions): ChildProcess {
  return crossSpawn(command, [...args], options);
}

export function fork(modulePath: string, args: readonly string[] = [], options: ForkOptions & Pick = {}): ChildProcess {
  return _fork(modulePath, [...args], options);
}

export interface WhichOptions {
  PATH?: string;
  PATHEXT?: string;
}

const DEFAULT_PATHEXT = TERMINAL_INFO.windows ? '.COM;.EXE;.BAT;.CMD' : undefined;

/**
 * Find the first instance of a program in PATH.
 *
 * If `program` contains a path separator, this function will merely return it.
 *
 * @param program A command name, such as `ionic`
 */
export async function which(program: string, { PATH = process.env.PATH, PATHEXT = process.env.PATHEXT || DEFAULT_PATHEXT }: WhichOptions = {}): Promise {
  if (program.includes(pathlib.sep)) {
    return program;
  }

  const results = await _findExecutables(program, { PATH });

  if (!results.length) {
github ionic-team / ionic-cli / packages / @ionic / utils-process / src / index.ts View on Github external
export function createProcessEnv(...sources: { [key: string]: string | undefined; }[]): NodeJS.ProcessEnv {
  return lodash.assign(TERMINAL_INFO.windows ? createCaseInsensitiveObject() : {}, ...sources);
}
github ionic-team / ionic-cli / packages / ionic / src / lib / utils / emoji.ts View on Github external
export function emoji(x: string, fallback: string): string {
  if (TERMINAL_INFO.windows) {
    return fallback;
  }

  return x;
}

@ionic/utils-terminal

Terminal utils for NodeJS

MIT
Latest version published 11 months ago

Package Health Score

80 / 100
Full package analysis

Similar packages