MCPcopy
hub / github.com/ionic-team/capacitor / checkInteractive

Function checkInteractive

cli/src/util/term.ts:8–29  ·  view source on GitHub ↗
(...args: string[])

Source from the content-addressed store, hash-verified

6// Given input variables to a command, make sure all are provided if the terminal
7// is not interactive (because we won't be able to prompt the user)
8export const checkInteractive = (...args: string[]): boolean => {
9 if (isInteractive()) {
10 return true;
11 }
12
13 // Fail if no args are provided, treat this as just a check of whether the term is
14 // interactive or not.
15 if (!args.length) {
16 return false;
17 }
18
19 // Make sure none of the provided args are empty, otherwise print the interactive
20 // warning and return false
21 if (args.filter((arg) => !arg).length) {
22 logger.error(
23 `Non-interactive shell detected.\n` +
24 `Run the command with ${c.input('--help')} to see a list of arguments that must be provided.`,
25 );
26 return false;
27 }
28 return true;
29};
30
31export const isInteractive = (): boolean => TERMINAL_INFO.tty && !TERMINAL_INFO.ci;

Callers 1

initCommandFunction · 0.90

Calls 2

isInteractiveFunction · 0.85
errorMethod · 0.80

Tested by

no test coverage detected