forked from microsoft/rushstack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExperimentsConfiguration.ts
More file actions
60 lines (53 loc) · 1.66 KB
/
ExperimentsConfiguration.ts
File metadata and controls
60 lines (53 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
import * as path from 'path';
import {
JsonFile,
JsonSchema,
FileSystem
} from '@rushstack/node-core-library';
/**
* This interface represents the raw experiments.json file which allows repo
* maintainers to enable and disable experimental Rush features.
* @beta
*/
export interface IExperimentsJson {
/**
* If this setting is enabled, incremental builds should use repo-wide dependency tracking
* instead of project-specific tracking.
*/
legacyIncrementalBuildDependencyDetection?: boolean;
}
/**
* Use this class to load the "common/config/rush/experiments.json" config file.
* This file allows repo maintainers to enable and disable experimental Rush features.
* @beta
*/
export class ExperimentsConfiguration {
private static _jsonSchema: JsonSchema = JsonSchema.fromFile(
path.resolve(__dirname, '..', 'schemas', 'experiments.schema.json')
);
private _experimentConfiguration: IExperimentsJson;
private _jsonFileName: string;
/**
* @internal
*/
public constructor(jsonFileName: string) {
this._jsonFileName = jsonFileName;
this._experimentConfiguration = {};
if (!FileSystem.exists(this._jsonFileName)) {
this._experimentConfiguration = {};
} else {
this._experimentConfiguration = JsonFile.loadAndValidate(
this._jsonFileName,
ExperimentsConfiguration._jsonSchema
);
}
}
/**
* Get the experiments configuration.
*/
public get configuration(): Readonly<IExperimentsJson> {
return this._experimentConfiguration;
}
}