mirror of
https://github.com/withastro/astro.git
synced 2025-04-14 23:51:49 -05:00
fix: support for Deno to install npm packages (#13548)
Co-authored-by: ematipico <602478+ematipico@users.noreply.github.com>
This commit is contained in:
parent
9520a23d9d
commit
e588527b4c
3 changed files with 17 additions and 1 deletions
7
.changeset/wet-onions-kick.md
Normal file
7
.changeset/wet-onions-kick.md
Normal file
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Support for Deno to install npm pacakges.
|
||||
|
||||
Deno requires npm prefix to install packages on npm. For example, to install react, we need to run `deno add npm:react`. But currently the command executed is `deno add react`, which doesn't work. So, we change the package names to have an npm prefix if you are using Deno.
|
|
@ -675,7 +675,12 @@ async function tryToInstallIntegrations({
|
|||
const installCommand = resolveCommand(packageManager?.agent ?? 'npm', 'add', inheritedFlags);
|
||||
if (!installCommand) return UpdateResult.none;
|
||||
|
||||
const installSpecifiers = await convertIntegrationsToInstallSpecifiers(integrations);
|
||||
const installSpecifiers = await convertIntegrationsToInstallSpecifiers(integrations).then(
|
||||
(specifiers) =>
|
||||
installCommand.command === 'deno'
|
||||
? specifiers.map((specifier) => `npm:${specifier}`) // Deno requires npm prefix to install packages
|
||||
: specifiers,
|
||||
);
|
||||
|
||||
const coloredOutput = `${bold(installCommand.command)} ${installCommand.args.join(' ')} ${cyan(installSpecifiers.join(' '))}`;
|
||||
const message = `\n${boxen(coloredOutput, {
|
||||
|
|
|
@ -70,6 +70,10 @@ async function installPackage(
|
|||
const installCommand = resolveCommand(packageManager?.agent ?? 'npm', 'add', []);
|
||||
if (!installCommand) return false;
|
||||
|
||||
if (installCommand.command === 'deno') {
|
||||
// Deno requires npm prefix to install packages
|
||||
packageNames = packageNames.map((name) => `npm:${name}`);
|
||||
}
|
||||
const coloredOutput = `${bold(installCommand.command)} ${installCommand.args.join(' ')} ${cyan(packageNames.join(' '))}`;
|
||||
const message = `\n${boxen(coloredOutput, {
|
||||
margin: 0.5,
|
||||
|
|
Loading…
Add table
Reference in a new issue