Skip to content

Commit

Permalink
fix(install-package): Automatically exit in CI instead of waiting for…
Browse files Browse the repository at this point in the history
… input (#10669)
  • Loading branch information
Princesseuh committed Apr 4, 2024
1 parent a8ab237 commit 0464563
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/neat-grapes-cry.md
@@ -0,0 +1,5 @@
---
"astro": patch
---

Fixes Astro waiting infinitely in CI when a required package was not installed
17 changes: 13 additions & 4 deletions packages/astro/src/cli/install-package.ts
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 0464563

Please sign in to comment.