mirror of
https://github.com/withastro/astro.git
synced 2024-12-16 21:46:22 -05:00
parent
1b8d302099
commit
8292c41311
2 changed files with 15 additions and 1 deletions
5
.changeset/nasty-olives-rush.md
Normal file
5
.changeset/nasty-olives-rush.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'create-astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Improve yarn berry support
|
|
@ -1,5 +1,7 @@
|
||||||
import { color } from '@astrojs/cli-kit';
|
import { color } from '@astrojs/cli-kit';
|
||||||
import { execa } from 'execa';
|
import { execa } from 'execa';
|
||||||
|
import path from 'node:path';
|
||||||
|
import fs from 'node:fs';
|
||||||
import { error, info, spinner, title } from '../messages.js';
|
import { error, info, spinner, title } from '../messages.js';
|
||||||
import type { Context } from './context';
|
import type { Context } from './context';
|
||||||
|
|
||||||
|
@ -46,10 +48,17 @@ export async function dependencies(
|
||||||
}
|
}
|
||||||
|
|
||||||
async function install({ pkgManager, cwd }: { pkgManager: string; cwd: string }) {
|
async function install({ pkgManager, cwd }: { pkgManager: string; cwd: string }) {
|
||||||
|
if (pkgManager === 'yarn') await ensureYarnLock({ cwd });
|
||||||
const installExec = execa(pkgManager, ['install'], { cwd });
|
const installExec = execa(pkgManager, ['install'], { cwd });
|
||||||
return new Promise<void>((resolve, reject) => {
|
return new Promise<void>((resolve, reject) => {
|
||||||
setTimeout(() => reject(`Request timed out after one minute`), 60_000);
|
setTimeout(() => reject(`Request timed out after 1m 30s`), 90_000);
|
||||||
installExec.on('error', (e) => reject(e));
|
installExec.on('error', (e) => reject(e));
|
||||||
installExec.on('close', () => resolve());
|
installExec.on('close', () => resolve());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function ensureYarnLock({ cwd }: { cwd: string }) {
|
||||||
|
const yarnLock = path.join(cwd, 'yarn.lock');
|
||||||
|
if (fs.existsSync(yarnLock)) return;
|
||||||
|
return fs.promises.writeFile(yarnLock, '', { encoding: 'utf-8' });
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue