Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
raw = read(arcDefaultPath)
arc = parse(raw)
}
else if (exists(appDotArcPath)) {
raw = read(appDotArcPath)
arc = parse(raw)
}
else if (exists(arcYamlPath)) {
raw = read(arcYamlPath)
arc = parse.yaml(raw)
// HACK
raw = parse.yaml.stringify(raw)
}
else if (exists(arcJsonPath)) {
raw = read(arcJsonPath)
arc = parse.json(raw)
// HACK
raw = parse.json.stringify(raw)
}
else {
throw Error('.arc, app.arc, arc.yaml, or arc.json not found')
}
}
catch(e) {
err('invalid arcfile in ' + cwd)
process.exit(1)
}
return {raw, arc}
}
function read(filepath, type) {
let arc = fs.readFileSync(filepath).toString()
try {
if (type === 'arc')
return parse(arc)
if (type === 'json')
return parse.json(arc)
if (type === 'yaml')
return parse.yaml(arc)
}
catch(err) {
throw Error(err)
}
}