From b29987d30c894eefcf904cc651c65dfa981a8a30 Mon Sep 17 00:00:00 2001 From: ymc9 <104139426+ymc9@users.noreply.github.com> Date: Thu, 16 Nov 2023 22:39:52 -0800 Subject: [PATCH] fix: support loading plugin.zmodel from a relative path --- packages/schema/src/cli/cli-util.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/schema/src/cli/cli-util.ts b/packages/schema/src/cli/cli-util.ts index eed22e2eb..d32a51b08 100644 --- a/packages/schema/src/cli/cli-util.ts +++ b/packages/schema/src/cli/cli-util.ts @@ -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(providerField.value); + let provider = getLiteral(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)) {