-
Notifications
You must be signed in to change notification settings - Fork 54
/
config.js
32 lines (24 loc) · 956 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
const {
env: { NETLIFY_TOKEN, CONTEXT },
} = require('process')
const resolveConfig = require('@netlify/config')
const { getConfigPath, getBaseDir } = require('@netlify/config')
const { logFlags, logConfigPath } = require('../log/main')
// Retrieve configuration object
const loadConfig = async function({ flags: { config, cwd }, flags: { token = NETLIFY_TOKEN, ...flags } }) {
logFlags(flags)
const flagsA = { ...DEFAULT_FLAGS, ...flags }
const configPath = await getConfigPath(config, cwd)
logConfigPath(configPath)
const baseDir = await getBaseDir(configPath)
try {
const netlifyConfig = await resolveConfig(configPath, flagsA)
return { netlifyConfig, configPath, token, baseDir }
} catch (error) {
error.message = `Netlify configuration error:\n${error.message}`
throw error
}
}
const DEFAULT_CONTEXT = 'production'
const DEFAULT_FLAGS = { context: CONTEXT || DEFAULT_CONTEXT }
module.exports = { loadConfig }