Skip to content

Commit

Permalink
Fix cli package resolution for @astrojs/db (#10338)
Browse files Browse the repository at this point in the history
  • Loading branch information
BryceRussell authored Mar 6, 2024
1 parent a2e9b2b commit 74cf1af
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/astro/src/cli/install-package.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createRequire } from 'node:module';
import { sep } from 'node:path';
import { pathToFileURL } from 'node:url';
import boxen from 'boxen';
import { execa } from 'execa';
import { bold, cyan, dim, magenta } from 'kleur/colors';
Expand Down Expand Up @@ -28,8 +29,8 @@ export async function getPackage<T>(
const packageJsonLoc = require.resolve(packageName + '/package.json', {
paths: [options.cwd ?? process.cwd()],
});
const packageLoc = packageJsonLoc.replace(`package.json`, 'dist/index.js');
const packageImport = await import(packageLoc);
const packageLoc = pathToFileURL(packageJsonLoc.replace(`package.json`, 'dist/index.js'));
const packageImport = await import(packageLoc.toString());
return packageImport as T;
}
await tryResolve(packageName, options.cwd ?? process.cwd());
Expand Down

0 comments on commit 74cf1af

Please sign in to comment.