Skip to content

Commit 66ab915

Browse files
authored
fix: support loading plugin.zmodel from a relative path (#837)
1 parent b962e05 commit 66ab915

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/schema/src/cli/cli-util.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,13 @@ export async function getPluginDocuments(services: ZModelServices, fileName: str
161161
if (isPlugin(decl)) {
162162
const providerField = decl.fields.find((f) => f.name === 'provider');
163163
if (providerField) {
164-
const provider = getLiteral<string>(providerField.value);
164+
let provider = getLiteral<string>(providerField.value);
165165
if (provider) {
166166
try {
167+
if (provider.startsWith('.')) {
168+
// resolve relative path against the schema file
169+
provider = path.resolve(path.dirname(fileName), provider);
170+
}
167171
const pluginEntrance = require.resolve(`${provider}`);
168172
const pluginModelFile = path.join(path.dirname(pluginEntrance), PLUGIN_MODULE_NAME);
169173
if (fs.existsSync(pluginModelFile)) {

0 commit comments

Comments
 (0)