-
-
Notifications
You must be signed in to change notification settings - Fork 152
/
Copy pathcreate-options.js
44 lines (39 loc) · 1.36 KB
/
create-options.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
44
'use strict';
const _ = require('lodash');
const path = require('path');
function createOptions(cwd, context) {
const options = {
cwd: cwd
};
if (!(process.platform === 'win32')) {
if (context.options.uid) options.uid = context.options.uid;
if (context.options.gid) options.gid = context.options.gid;
}
options.env = Object.create(process.env);
options.env['npm_config_loglevel'] = context.options.npmLevel;
options.env['npm_config_tmp'] = context.npmConfigTmp;
options.env['TEMP'] = context.npmConfigTmp;
options.env['TMP'] = context.npmConfigTmp;
options.env['TMPDIR'] = context.npmConfigTmp;
// Explicitly tell yarn to ignore the "engines" field in `package.json`.
// If dependencies of tested modules have set it and CITGM is testing an
// unreleased version of Node.js, this prevents `yarn install` from failing.
options.env['YARN_IGNORE_ENGINES'] = 'true';
if (context.options.nodedir) {
const nodedir = path.resolve(process.cwd(), context.options.nodedir);
options.env['npm_config_nodedir'] = nodedir;
context.emit(
'data',
'verbose',
`${context.module.name} nodedir`,
`Using nodedir "${nodedir}"`
);
}
if (context.module && context.module.envVar) {
_.forEach(context.module.envVar, (val, key) => {
options.env[key] = val;
});
}
return options;
}
module.exports = createOptions;