UNPKG

@nxrocks/common

Version:

Common library to share code among the `@nxrocks/*` plugins.

25 lines 961 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.addPluginToNxJson = addPluginToNxJson; const devkit_1 = require("@nx/devkit"); function addPluginToNxJson(pluginName, tree, options, ...cacheableOperations) { // const nxJson = (0, devkit_1.readNxJson)(tree); if (!nxJson) { throw new Error(`${pluginName} requires nx.json to be present in the workspace`); } nxJson.plugins ??= []; if (!nxJson.plugins.some((p) => typeof p === 'string' ? p === pluginName : p.plugin === pluginName)) { nxJson.plugins.push({ plugin: pluginName, ...(options ? { options } : {}), }); } nxJson.targetDefaults ??= {}; for (const target of cacheableOperations) { nxJson.targetDefaults[target] ??= {}; nxJson.targetDefaults[target].cache ??= true; } (0, devkit_1.updateNxJson)(tree, nxJson); } //# sourceMappingURL=add-plugin-to-nx-json.js.map