-
Notifications
You must be signed in to change notification settings - Fork 53
/
config.js
99 lines (86 loc) · 3.07 KB
/
config.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import path from 'path'
const {env, platform, execPath} = process
/**
* boolean value indicating whether or not we're running on `win32` (Windows).
* @type {Boolean}
*/
export const isWindows = platform === 'win32'
/**
* absolute location of the user's home directory.
* @type {String}
*/
export const home = env[isWindows ? 'USERPROFILE' : 'HOME']
/**
* registry endpoint configured via `IED_REGISTRY`, defaults to the npm
* registry [`https://registry.npmjs.org/`]('https://registry.npmjs.org/').
* @type {String}
*/
export const registry = env.IED_REGISTRY || 'https://registry.npmjs.org/'
/**
* cache directory used for storing downloaded package tarballs. configurable
* via `IED_CACHE_DIR`, default to `.ied_cache` in the user's home directory.
* @type {String}
*/
export const cacheDir = env.IED_CACHE_DIR || path.join(home, '.ied_cache')
/**
* directory used for globally installed `node_modules`.
* configurable via `IED_GLOBAL_NODE_MODULES`, default to `.node_modules` in
* the user's home directory.
* @type {String}
*/
export const globalNodeModules = env.IED_GLOBAL_NODE_MODULES ||
path.join(home, '.node_modules')
/**
* similar to {@link globalNodeModules}. directory used for symlinks of
* globally linked executables.
* configurable via `IED_GLOBAL_BIN`, default to parent of `process.execPath`
* (location of `node` binary).
* @type {String}
*/
export const globalBin = env.IED_GLOBAL_BIN || path.resolve(execPath, '..')
/**
* proxy server endpoint. can be set via `IED_PROXY` or `http_proxy`. optional
* and default to `null`.
* @type {String|null}
*/
export const proxy = env.IED_PROXY || env.http_proxy || null
/**
* how often `ied` should retry HTTP requests before indicating failure.
* defaults to `5` requests. can be set via `IED_REQUEST_RETRIES`.
* @type {Number}
*/
export const retries = parseInt(env.IED_REQUEST_RETRIES, 10) || 5
/**
* shell command used for executing lifecycle scripts (such as `postinstall`).
* platform dependent: default to `cmd` on Windows, otherwise use `sh`.
* can be overridden using `IED_SH`.
* @type {String}
*/
export const sh = env.IED_SH || env.SHELL || (platform === 'win32' ? env.comspec || 'cmd' : 'sh')
/**
* additional flags supplied to the `sh` executable. platform dependent:
* default to `/d /s /c` on Windows, otherwise use `-c`.
* can be overridden using `IED_SH_FLAG`.
* @type {String}
*/
export const shFlag = env.IED_SH_FLAG || (isWindows ? '/d /s /c' : '-c')
/**
* bearer token used for downloading access restricted packages (scoped
* modules). this token will be set as `Authorization` header field on all
* subsequent HTTP requests to the registry, thus exposing a potential
* **security** risk.
* @type {String|null}
*/
export const bearerToken = env.IED_BEARER_TOKEN || null
/**
* HTTP options supplied as part of all subsequent requests. used for exporting
* generic HTTP options that contain the proxy configuration (if set) and the
* `Authorization` header.
* @type {Object}
*/
export const httpOptions = {
proxy,
headers: bearerToken
? {authorization: `Bearer ${bearerToken}`}
: {}
}