-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy pathprint-expansions.js
43 lines (34 loc) · 1.03 KB
/
print-expansions.js
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
/* istanbul ignore file */
'use strict';
const YAML = require('yaml');
const fs = require('fs');
const path = require('path');
const os = require('os');
/**
* Imports expansions written to disk to the process env so
* we don't getting logging of our keys in Evergreen.
*/
const printExpansions = () => {
const filter = process.argv.slice(2);
if (!process.env.EVERGREEN_EXPANSIONS_PATH) {
return;
}
const expansionsPath = path.resolve(process.env.EVERGREEN_EXPANSIONS_PATH);
if (!fs.existsSync(expansionsPath)) {
console.error({
platform: os.platform(),
cwd: process.cwd(),
expansionsPath
});
throw new Error(`printExpansions failed: file ${expansionsPath} not found`);
}
const data = fs.readFileSync(expansionsPath, 'utf8');
const expansions = YAML.parse(data);
console.log(
Object.keys(expansions)
.filter((expansion) => filter.length === 0 || filter.includes(expansion))
.map((key) => `${key.toUpperCase()}="${expansions[key]}"`)
.join('\n')
);
};
printExpansions();