Skip to content

Commit

Permalink
fix: support loading plugin.zmodel from a relative path (#837)
Browse files Browse the repository at this point in the history
  • Loading branch information
ymc9 authored Nov 17, 2023
1 parent b962e05 commit 66ab915
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/schema/src/cli/cli-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,13 @@ export async function getPluginDocuments(services: ZModelServices, fileName: str
if (isPlugin(decl)) {
const providerField = decl.fields.find((f) => f.name === 'provider');
if (providerField) {
const provider = getLiteral<string>(providerField.value);
let provider = getLiteral<string>(providerField.value);
if (provider) {
try {
if (provider.startsWith('.')) {
// resolve relative path against the schema file
provider = path.resolve(path.dirname(fileName), provider);
}
const pluginEntrance = require.resolve(`${provider}`);
const pluginModelFile = path.join(path.dirname(pluginEntrance), PLUGIN_MODULE_NAME);
if (fs.existsSync(pluginModelFile)) {
Expand Down

0 comments on commit 66ab915

Please sign in to comment.