Skip to content

Commit 2b8a02b

Browse files
realtimetodiejkrems
authored andcommittedDec 12, 2024·
feat(@angular-devkit/architect): require build schemas from modules
1 parent 615428b commit 2b8a02b

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed
 

‎packages/angular_devkit/architect/node/node-modules-architect-host.ts

+16-2
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ export class WorkspaceNodeModulesArchitectHost implements ArchitectHost<NodeModu
193193
}
194194

195195
// Determine builder option schema path (relative within package only)
196-
const schemaPath = builder.schema && path.normalize(builder.schema);
196+
let schemaPath = builder.schema && path.normalize(builder.schema);
197197
if (!schemaPath) {
198198
throw new Error('Could not find the schema for builder ' + builderStr);
199199
}
@@ -203,7 +203,21 @@ export class WorkspaceNodeModulesArchitectHost implements ArchitectHost<NodeModu
203203
);
204204
}
205205

206-
const schemaText = readFileSync(path.join(buildersManifestDirectory, schemaPath), 'utf-8');
206+
// The file could be either a package reference or in the local manifest directory.
207+
// Node resolution is tried first then reading the file from the manifest directory if resolution fails.
208+
try {
209+
schemaPath = localRequire.resolve(schemaPath, {
210+
paths: [buildersManifestDirectory],
211+
});
212+
} catch (e) {
213+
if ((e as NodeJS.ErrnoException).code === 'MODULE_NOT_FOUND') {
214+
schemaPath = path.join(buildersManifestDirectory, schemaPath);
215+
} else {
216+
throw e;
217+
}
218+
}
219+
220+
const schemaText = readFileSync(schemaPath, 'utf-8');
207221

208222
return Promise.resolve({
209223
name: builderStr,

0 commit comments

Comments
 (0)
Please sign in to comment.