@rushstack/heft-config-file
Version:
Configuration file loader for @rushstack/heft
66 lines • 2.9 kB
JavaScript
;
// 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.NonProjectConfigurationFile = void 0;
const node_core_library_1 = require("@rushstack/node-core-library");
const ConfigurationFileBase_1 = require("./ConfigurationFileBase");
/**
* @beta
*/
class NonProjectConfigurationFile extends ConfigurationFileBase_1.ConfigurationFileBase {
/**
* Load the configuration file at the specified absolute path, automatically resolving
* `extends` properties. Will throw an error if the file cannot be found.
*/
loadConfigurationFile(terminal, filePath) {
return this._loadConfigurationFileInnerWithCache(terminal, filePath, new Set(), undefined);
}
/**
* Load the configuration file at the specified absolute path, automatically resolving
* `extends` properties. Will throw an error if the file cannot be found.
*/
async loadConfigurationFileAsync(terminal, filePath) {
return await this._loadConfigurationFileInnerWithCacheAsync(terminal, filePath, new Set(), undefined);
}
/**
* This function is identical to {@link NonProjectConfigurationFile.loadConfigurationFile}, except
* that it returns `undefined` instead of throwing an error if the configuration file cannot be found.
*/
tryLoadConfigurationFile(terminal, filePath) {
try {
return this.loadConfigurationFile(terminal, filePath);
}
catch (e) {
if (node_core_library_1.FileSystem.isNotExistError(e)) {
return undefined;
}
throw e;
}
}
/**
* This function is identical to {@link NonProjectConfigurationFile.loadConfigurationFileAsync}, except
* that it returns `undefined` instead of throwing an error if the configuration file cannot be found.
*/
async tryLoadConfigurationFileAsync(terminal, filePath) {
try {
return await this.loadConfigurationFileAsync(terminal, filePath);
}
catch (e) {
if (node_core_library_1.FileSystem.isNotExistError(e)) {
return undefined;
}
throw e;
}
}
_tryLoadConfigurationFileInRig(terminal, rigConfig, visitedConfigurationFilePaths) {
// This is a no-op because we don't support rigging for non-project configuration files
return undefined;
}
async _tryLoadConfigurationFileInRigAsync(terminal, rigConfig, visitedConfigurationFilePaths) {
// This is a no-op because we don't support rigging for non-project configuration files
return undefined;
}
}
exports.NonProjectConfigurationFile = NonProjectConfigurationFile;
//# sourceMappingURL=NonProjectConfigurationFile.js.map