🎥 Make videos programmatically with React
fix git detection on windows
Jonny Burgerd4d2ceac8ee0
diff --git a/packages/create-video/src/init.ts b/packages/create-video/src/init.tsindex 142f41675f..4787996d25 100644--- a/packages/create-video/src/init.ts+++ b/packages/create-video/src/init.ts@@ -1,6 +1,5 @@import chalk from 'chalk';import execa from 'execa';-import os from 'os';import {createYarnYmlFile} from './add-yarn2-support';import {degit} from './degit';import {getLatestRemotionVersion} from './latest-remotion-version';@@ -18,11 +17,9 @@ import {resolveProjectRoot} from './resolve-project-root';import {selectTemplate} from './select-template';import {yesOrNo} from './yesno';-const binaryExists = (name: string) => {- const isWin = os.platform() === 'win32';- const where = isWin ? 'where' : 'which';+const gitExists = (commandToCheck: string) => {try {- execa.sync(where, [name]);+ execa.sync(commandToCheck);return true;} catch (err) {return false;@@ -31,18 +28,18 @@ const binaryExists = (name: string) => {export const checkGitAvailability = async (cwd: string,- command: string+ commandToCheck: string): Promise<| {type: 'no-git-repo'}| {type: 'is-git-repo'; location: string}| {type: 'git-not-installed'}> => {- if (!binaryExists(command)) {+ if (!gitExists(commandToCheck)) {return {type: 'git-not-installed'};}try {- const result = await execa(command, ['rev-parse', '--show-toplevel'], {+ const result = await execa('git', ['rev-parse', '--show-toplevel'], {cwd,});return {type: 'is-git-repo', location: result.stdout};@@ -74,7 +71,7 @@ const getGitStatus = async (root: string): Promise<void> => {};export const init = async () => {- const result = await checkGitAvailability(process.cwd(), 'git');+ const result = await checkGitAvailability(process.cwd(), '--version');if (result.type === 'git-not-installed') {Log.error('Git is not installed or not in the path. Install Git to continue.'diff --git a/packages/create-video/src/test/git-status.test.ts b/packages/create-video/src/test/git-status.test.tsindex 921f16ab9e..e67231007b 100644--- a/packages/create-video/src/test/git-status.test.ts+++ b/packages/create-video/src/test/git-status.test.ts@@ -3,7 +3,7 @@ import {expect, test} from 'vitest';import {checkGitAvailability} from '../init';test('Get git status', async () => {- const status = await checkGitAvailability(process.cwd(), 'git');+ const status = await checkGitAvailability(process.cwd(), 'git --version');expect(status).toEqual({type: 'is-git-repo',location: path.posix@@ -17,13 +17,13 @@ test('Get git status', async () => {const status2 = await checkGitAvailability(path.dirname(status.location),- 'git'+ 'git --version');expect(status2).toEqual({type: 'no-git-repo'});const status3 = await checkGitAvailability(path.dirname(status.location),- 'wronggitbinary'+ 'wronggitbinary --version');expect(status3).toEqual({type: 'git-not-installed'});});