UNPKG

@o3r/core

Version:
35 lines 1.79 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const node_child_process_1 = require("node:child_process"); const fs = require("node:fs"); const node_path_1 = require("node:path"); const architect_1 = require("@angular-devkit/architect"); const schematics_1 = require("@o3r/schematics"); const utils_1 = require("../utils"); exports.default = (0, architect_1.createBuilder)((0, utils_1.createBuilderWithMetricsIfInstalled)(async (options, context) => { context.reportRunning(); context.reportProgress(1, 1, `Running ${options.script} !!!`); const specifiedRoot = context.target?.project && (await context.getProjectMetadata(context.target.project)).root; const projectRoot = specifiedRoot ? (0, node_path_1.resolve)(context.workspaceRoot, specifiedRoot) : context.currentDirectory; const angularJsonPath = (0, node_path_1.join)(context.workspaceRoot, 'angular.json'); const angularJson = fs.existsSync(angularJsonPath) ? JSON.parse(fs.readFileSync(angularJsonPath, { encoding: 'utf8' }).toString()) : undefined; if (!angularJson) { context.logger.warn(`angular.json file cannot be found by @o3r/core:${context.builder.builderName} builder. Detection of package manager runner will fallback on the one used to execute the actual command.`); } const pmr = (0, schematics_1.getPackageManagerRunner)(angularJson); try { (0, node_child_process_1.execSync)(`${pmr} ${options.script}`, { stdio: ['inherit', 'inherit', 'inherit'], cwd: projectRoot, env: { ...process.env } }); return { success: true }; } catch (e) { return { success: false, error: e.message || e.toString() }; } })); //# sourceMappingURL=index.js.map