0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-01-06 22:10:10 -05:00

Fix cli package resolution for @astrojs/db (#10338)

This commit is contained in:
Bryce Russell 2024-03-06 09:37:08 -06:00 committed by GitHub
parent a2e9b2b936
commit 74cf1af86e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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';
@ -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());