Home / Function/ getExecInputForPlatform() — astro Function Reference

getExecInputForPlatform() — astro Function Reference

Architecture documentation for the getExecInputForPlatform() function in cli-clipboard.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  bdb8cade_1848_e664_6a3e_430f16db9d94["getExecInputForPlatform()"]
  c4fcd5ce_4a96_8071_9d35_f40a368f2892["cli-clipboard.ts"]
  bdb8cade_1848_e664_6a3e_430f16db9d94 -->|defined in| c4fcd5ce_4a96_8071_9d35_f40a368f2892
  3ad241c4_c0ac_6abd_74d9_bace3166794d["copy()"]
  3ad241c4_c0ac_6abd_74d9_bace3166794d -->|calls| bdb8cade_1848_e664_6a3e_430f16db9d94
  style bdb8cade_1848_e664_6a3e_430f16db9d94 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/cli/info/infra/cli-clipboard.ts lines 5–34

async function getExecInputForPlatform({
	platform,
	commandExecutor,
}: {
	commandExecutor: CommandExecutor;
	platform: NodeJS.Platform;
}): Promise<[command: string, args?: Array<string>] | null> {
	if (platform === 'darwin') {
		return ['pbcopy'];
	}
	if (platform === 'win32') {
		return ['clip'];
	}
	// Unix: check if a supported command is installed
	const unixCommands: Array<[string, Array<string>]> = [
		['xclip', ['-selection', 'clipboard']],
		['wl-copy', []],
	];
	for (const [unixCommand, unixArgs] of unixCommands) {
		try {
			const { stdout } = await commandExecutor.execute('which', [unixCommand]);
			if (stdout.trim()) {
				return [unixCommand, unixArgs];
			}
		} catch {
			continue;
		}
	}
	return null;
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does getExecInputForPlatform() do?
getExecInputForPlatform() is a function in the astro codebase, defined in packages/astro/src/cli/info/infra/cli-clipboard.ts.
Where is getExecInputForPlatform() defined?
getExecInputForPlatform() is defined in packages/astro/src/cli/info/infra/cli-clipboard.ts at line 5.
What calls getExecInputForPlatform()?
getExecInputForPlatform() is called by 1 function(s): copy.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free