Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
config: path.resolve('autocannon.yml'),
flamegraph: false
}
})
if (!hasFile(args.config)) {
help.toStdout()
return
}
// should never throw, we have just
// checked if we can access this
const data = fs.readFileSync(args.config, 'utf8')
try {
var config = YAML.parse(data)
} catch (err) {
console.error(err)
process.exit(1)
}
var exec = nodePath
if (args.flamegraph) {
if (isWin) {
console.error('flamegraphs are supported only on Linux and Mac OS X')
process.exit(1)
}
exec = zeroX
config.server = '--svg ' + config.server
}
const get = async (input) => {
const option = Object.assign({}, input);
option.device = option.device || await getDevice();
const config = joi.attempt(option, joi.object({
device : joi.string().required()
}).required());
const output = await manage.get(config.device);
if (!output) {
throw new TypeError(`Unable to get proxy configuration. No output to parse.`);
}
const parsed = yaml.parse(output);
// OS X answers with less than ideal property names.
// We normalize them here before anyone sees it.
return {
hostname : parsed.Server,
port : parsed.Port,
enabled : isOn(parsed.Enabled)
};
};
function loadEnvConfig(env) {
try {
let configPath = path.join(CONFIG_PATH, env + '.yml');
let configYaml = fs.readFileSync(configPath).toString();
return YAML.parse(configYaml);
}
catch (e) {
if (env === 'development') {
return loadEnvConfig('dev');
}
if (env === 'production') {
return loadEnvConfig('production');
}
if (env !== 'local') {
console.warn(
chalk.yellow('Could not load environment configuration file'),
chalk.magenta(env + '.yml')
);
}
return {};
}
function readRc(fname) {
const rcFname = Path.basename(fname);
try {
const rcData = Fs.readFileSync(fname).toString();
let rc;
try {
assert(rcFname === ".fynrc" && rcData.startsWith("---"));
rc = Yaml.parse(rcData);
logger.debug(`Loaded ${rcFname} YAML RC`, fname, JSON.stringify(rc));
} catch (e) {
rc = Ini.parse(rcData);
logger.debug(`Loaded ${rcFname} ini RC`, fname, JSON.stringify(rc));
}
return rc;
} catch (e) {
if (e.code !== "ENOENT") {
logger.error(`Failed to process ${rcFname} RC file`, fname, e.message);
}
return {};
}
}
.map(async (filename) => {
const content = await readFile(path.join(artifactsPath, filename))
try {
if (filename.match(/\.json$/i)) {
return [filename, JSON.parse(content)]
}
return [filename, yml.parse(content)]
} catch (error) {
ctx.sls.cli.log(
`(Safeguards) Failed to parse file ${filename} in the artifacts directory.`,
`Serverless Enterprise`
)
throw error
}
})
)
parse: function parseJsonYamlMarkdown(context, nextParser) {
var YAML = require('yamljs');
var filePath = context.path;
var ext = filePath.substr(-5);
var data = context.data;
var item = ext === '.json'
? JSON.parse(data)
: ext === '.yaml'
? YAML.parse(data)
: filePath.substr(-8) === '.yaml.md'
? parseYamlMarkdown(data)
: null;
if (item) {
context.item = Object.assign(context.item || {}, item);
}
nextParser();
}
};
function GetParsedFile(fileName, document) {
var fileContent = document.getText();
if (document.languageId === "json") {
return JSON.parse(fileContent);
} else if (document.languageId === "yaml") {
return YAML.parse(fileContent);
} else if (document.languageId === "plaintext") {
if (fileContent.match(/^\s*[{[]/)) {
return JSON.parse(fileContent);
} else {
return YAML.parse(fileContent);
}
}
}
code: markdownProps => {
const language = markdownProps.className
if (!language) return <code>{markdownProps.children}</code>
else if (['lang-js', 'lang-jsx'].includes(language)) {
return (
<div>
</div>
)
} else if (language === 'lang-meta') {
const metadata = yaml.parse(markdownProps.children)
return
} else {
return null
}
},
Alert,
async _loadManifest () {
try {
let rawManifest = await fs.readFileAsync(this.manifestPath);
let manifest = YAML.parse(rawManifest.toString());
let valid = await dataValidator.validateOtaManifest(manifest, this.dataDir);
if (!valid) {
return null;
}
return manifest;
} catch (err) {
log.error('OTA manifest cannot be parsed');
return null;
}
}
function readYAMLConfig (filename) {
return yaml.parse(fs.readFileSync(filename, 'utf-8'))
}