Skip to content

Commit

Permalink
Terminal Fix command check for Windows in create
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Hall committed Nov 23, 2024
1 parent 512c338 commit ec94676
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/create-catalyst/src/commands/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ import { parse } from '../utils/parse';
import { Telemetry } from '../utils/telemetry/telemetry';
import { writeEnv } from '../utils/write-env';

function getPlatformCheckCommand(command: string): string {
const isWindows = process.platform === 'win32';
return isWindows ? `where.exe ${command}` : `which ${command}`;
}

const telemetry = new Telemetry();

export const create = new Command('create')
Expand Down Expand Up @@ -43,14 +48,14 @@ export const create = new Command('create')
const { ghRef, repository } = options;

try {
execSync('which git', { stdio: 'ignore' });
execSync(getPlatformCheckCommand('git'), { stdio: 'ignore' });
} catch {
console.error(chalk.red('Error: git is required to create a Catalyst project\n'));
process.exit(1);
}

try {
execSync('which pnpm', { stdio: 'ignore' });
execSync(getPlatformCheckCommand('pnpm'), { stdio: 'ignore' });
} catch {
console.error(chalk.red('Error: pnpm is required to create a Catalyst project\n'));
console.error(chalk.yellow('Tip: Enable it by running `corepack enable pnpm`\n'));
Expand Down

0 comments on commit ec94676

Please sign in to comment.