Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async getConfig() {
try {
return await getConfigPath()
} catch (error) {
try {
return await getConfigPath(undefined, this.netlify.site.root)
} catch (error) {
console.error(error.message)
this.exit(1)
}
}
}
}
async getConfig() {
try {
return await getConfigPath()
} catch (error) {
try {
return await getConfigPath(undefined, this.netlify.site.root)
} catch (error) {
console.error(error.message)
this.exit(1)
}
}
}
}
async function getAll(projectPath) {
const rulesUnique = new Set()
const configPath = await getConfigPath(undefined, projectPath)
const redirectsFilePath = path.resolve(projectPath, '_redirects')
if (fs.existsSync(redirectsFilePath)) {
const fileName = redirectsFilePath
.split(path.sep)
.pop();
(await parseFile(parseRedirectsFormat, fileName, redirectsFilePath))
.forEach(r => rulesUnique.add(JSON.stringify(r)))
}
if (fs.existsSync(configPath)) {
const fileName = configPath
.split(path.sep)
.pop();
(await parseFile(parseNetlifyConfig, fileName, configPath))
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
}
}