/
githubmirror
/
strapi
Обзор
Документация
Войти
/
githubmirror
/
strapi
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
packages/cli/create-strapi-app/src/utils/git.ts
41 строка
1 KB
Nico André
chore(lint): add non-blocking oxlint setup (#26923)
31 июл 2026, 16:56
Не верифицирован
31 июл 2026, 16:56
6469af3
Код
Авторство
О чём код?
import execa from 'execa'; async function isInGitRepository(rootDir: string) { try { await execa('git', ['rev-parse', '--is-inside-work-tree'], { stdio: 'ignore', cwd: rootDir }); return true; } catch { return false; } } async function isInMercurialRepository(rootDir: string) { try { await execa('hg', ['-cwd', '.', 'root'], { stdio: 'ignore', cwd: rootDir }); return true; } catch { return false; } } export async function tryGitInit(rootDir: string) { try { await execa('git', ['--version'], { stdio: 'ignore' }); if ((await isInGitRepository(rootDir)) || (await isInMercurialRepository(rootDir))) { return false; } await execa('git', ['init'], { stdio: 'ignore', cwd: rootDir }); await execa('git', ['add', '.'], { stdio: 'ignore', cwd: rootDir }); await execa('git', ['commit', '-m', 'Initial commit from Strapi'], { stdio: 'ignore', cwd: rootDir, }); return true; } catch (e) { console.error('Error while trying to initialize git:', e); return false; } }