UNPKG

@rushstack/heft

Version:

Build all your JavaScript projects the same way: A way that works.

52 lines 2.94 kB
"use strict"; // Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. // See LICENSE in the project root for license information. Object.defineProperty(exports, "__esModule", { value: true }); exports.HeftTaskSession = void 0; const tapable_1 = require("tapable"); const node_core_library_1 = require("@rushstack/node-core-library"); class HeftTaskSession { get parameters() { // Delay loading the parameters for the task until they're actually needed if (!this._parameters) { const parameterManager = this._options.internalHeftSession.parameterManager; const task = this._options.task; this._parameters = parameterManager.getParametersForPlugin(task.pluginDefinition); } return this._parameters; } get parsedCommandLine() { return this._parsedCommandLine; } constructor(options) { const { internalHeftSession: { heftConfiguration: { tempFolderPath: tempFolder }, loggingManager, metricsCollector }, phase, task } = options; if (!options.internalHeftSession.parsedCommandLine) { // This should not happen throw new node_core_library_1.InternalError('Attempt to construct HeftTaskSession before command line has been parsed'); } this._parsedCommandLine = options.internalHeftSession.parsedCommandLine; this.logger = loggingManager.requestScopedLogger(`${phase.phaseName}:${task.taskName}`); this.metricsCollector = metricsCollector; this.taskName = task.taskName; this.hooks = { run: new tapable_1.AsyncParallelHook(['runHookOptions']), runIncremental: new tapable_1.AsyncParallelHook(['runIncrementalHookOptions']), registerFileOperations: new tapable_1.AsyncSeriesWaterfallHook(['fileOperations']) }; // Guaranteed to be unique since phases are uniquely named, tasks are uniquely named within // phases, and neither can have '/' in their names. We will also use the phase name and // task name as the folder name (instead of the plugin name) since we want to enable re-use // of plugins in multiple phases and tasks while maintaining unique temp/cache folders for // each task. // Having a parent folder for the phase simplifies interaction with the Rush build cache. const uniqueTaskFolderName = `${phase.phaseName}/${task.taskName}`; // <projectFolder>/temp/<phaseName>/<taskName> this.tempFolderPath = `${tempFolder}/${uniqueTaskFolderName}`; this._options = options; } requestAccessToPluginByName(pluginToAccessPackage, pluginToAccessName, pluginApply) { this._options.pluginHost.requestAccessToPluginByName(this.taskName, pluginToAccessPackage, pluginToAccessName, pluginApply); } } exports.HeftTaskSession = HeftTaskSession; //# sourceMappingURL=HeftTaskSession.js.map