mirror of
https://github.com/withastro/astro.git
synced 2025-02-17 22:44:24 -05:00
fix(install-package): Automatically exit in CI instead of waiting for input (#10669)
This commit is contained in:
parent
a8ab23700f
commit
0464563e52
2 changed files with 18 additions and 4 deletions
5
.changeset/neat-grapes-cry.md
Normal file
5
.changeset/neat-grapes-cry.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"astro": patch
|
||||
---
|
||||
|
||||
Fixes Astro waiting infinitely in CI when a required package was not installed
|
|
@ -8,6 +8,7 @@ import prompts from 'prompts';
|
|||
import resolvePackage from 'resolve';
|
||||
import whichPm from 'which-pm';
|
||||
import { type Logger } from '../core/logger/core.js';
|
||||
import ci from 'ci-info';
|
||||
const require = createRequire(import.meta.url);
|
||||
|
||||
type GetPackageOptions = {
|
||||
|
@ -38,10 +39,18 @@ export async function getPackage<T>(
|
|||
return packageImport as T;
|
||||
} catch (e) {
|
||||
if (options.optional) return undefined;
|
||||
logger.info(
|
||||
'SKIP_FORMAT',
|
||||
`To continue, Astro requires the following dependency to be installed: ${bold(packageName)}.`
|
||||
);
|
||||
let message = `To continue, Astro requires the following dependency to be installed: ${bold(packageName)}.`;
|
||||
|
||||
if (ci.isCI) {
|
||||
message += ` Packages cannot be installed automatically in CI environments.`;
|
||||
}
|
||||
|
||||
logger.info('SKIP_FORMAT', message);
|
||||
|
||||
if (ci.isCI) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const result = await installPackage([packageName, ...otherDeps], options, logger);
|
||||
|
||||
if (result) {
|
||||
|
|
Loading…
Add table
Reference in a new issue