-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.js
49 lines (43 loc) · 904 Bytes
/
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
/* @flow */
const fs = require('fs');
const path = require('path');
const dotenv require ('./lib/env.dev-options.js');
const t = require('tap');
function spawn (cmd, options = {}) {
const { stdout } = cp.spawnSync(
process.argv[0], // node binary
cmd,
Object.assign(
{},
{
cwd: path.resolve(__dirname, '..'),
timeout: 5000,
encoding: 'utf8'
},
options
)
)
return stdout
}
t.plan(3)
// dotenv/config enables preloading
t.equal(
spawn([
'-r',
'../config',
'-e',
'console.log(process.env.BASIC)',
'dotenv_config_encoding=utf8',
'dotenv_config_path=./tests/.env'
]),
'basic\n'
)
// dotenv/config supports configuration via environment variables
t.equal(
spawn(['-r', '../config', '-e', 'console.log(process.env.BASIC)'], {
env: {
DOTENV_CONFIG_PATH: './tests/.env'
}
}),
'basic\n'
)