Skip to content

Commit

Permalink
feat(@angular-devkit/architect): require build schemas from modules
Browse files Browse the repository at this point in the history
  • Loading branch information
realtimetodie authored and jkrems committed Dec 12, 2024
1 parent 615428b commit 2b8a02b
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export class WorkspaceNodeModulesArchitectHost implements ArchitectHost<NodeModu
}

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

const schemaText = readFileSync(path.join(buildersManifestDirectory, schemaPath), 'utf-8');
// The file could be either a package reference or in the local manifest directory.
// Node resolution is tried first then reading the file from the manifest directory if resolution fails.
try {
schemaPath = localRequire.resolve(schemaPath, {
paths: [buildersManifestDirectory],
});
} catch (e) {
if ((e as NodeJS.ErrnoException).code === 'MODULE_NOT_FOUND') {
schemaPath = path.join(buildersManifestDirectory, schemaPath);
} else {
throw e;
}
}

const schemaText = readFileSync(schemaPath, 'utf-8');

return Promise.resolve({
name: builderStr,
Expand Down

0 comments on commit 2b8a02b

Please sign in to comment.