Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const readClientsFile = async (repoPath: string): Promise => {
const yaml = await readFile(clientsFilePath(repoPath));
// TODO: Maybe use a schema w/ safeLoad?
return Yaml.safeLoad(yaml.toString());
};
const fs = require('fs');
const path = require('path');
const async = require('async');
const parseFrontMatter = require('hexo-front-matter').parse;
const moment = require('moment');
const yaml = require('js-yaml');
const utils = require('./utils');
const readFileAsString = utils.readFileAsString;
const orderBy = utils.orderBy;
const configFile = fs.readFileSync('_config.yml', 'utf8');
const config = yaml.safeLoad(configFile).server;
const postsDirectory = path.join(process.cwd(), 'source/_posts');
const getLatestPosts = (options) => {
return new Promise((resolve, reject) => {
options.offset = options.offset || 0;
options.limit = options.limit || 10;
options.include = options.include || [];
fs.readdir(postsDirectory, (err, filenames) => {
if (err) {
return reject(err);
}
const postFilenames = filenames.filter(filename => filename.indexOf('.md') !== -1);
const fullpaths = postFilenames.map(filename => path.join(postsDirectory, filename));
const slugs = postFilenames.map(filename => filename.slice(0, -3));
'use strict';
const fs = require('fs');
const yaml = require('js-yaml');
const applicator = require('./index.js');
const argv = require('tiny-opts-parser')(process.argv);
if (argv.v) argv.verbose = argv.v;
if (argv._.length>=3) {
const overlay = yaml.safeLoad(fs.readFileSync(argv._[2],'utf8'),{json:true});
const openapiStr = fs.readFileSync(argv._[3],'utf8');
const json = (openapiStr.startsWith('{'));
const openapi = yaml.safeLoad(openapiStr,{json:true});
if (overlay.overlay) {
if (overlay.overlay.description) {
console.warn('Applying',overlay.overlay.description);
}
const result = applicator.apply(overlay,openapi,argv);
if (json)
console.log(JSON.stringify(result,null,2));
else
console.log(yaml.safeDump(result));
}
else {
console.warn(argv._[2],'does not seem to be a valid overlay document');
}
}
else {
console.log('Usage: apply {overlayfile} {openapifile} [-v|--verbose]');
handler: (argv) => {
const chaptersPath = path.resolve(process.cwd(), 'chapters.yml');
const chaptersContent = fs.readFileSync(chaptersPath, 'utf8');
const chaptersArr = yaml.safeLoad(chaptersContent);
const cfgPath = path.resolve(process.cwd(), 'loppo.yml');
const cfgContent = fs.readFileSync(cfgPath, 'utf8');
const cfgObj = yaml.safeLoad(cfgContent);
const docDir = cfgObj.dir;
const filesArr = [];
chaptersArr
.filter(c => Object.keys(c)[0].substr(-3) === '.md')
.forEach((c) => {
const fileName = Object.keys(c)[0];
const filePath = path.resolve(process.cwd(), docDir, fileName);
let fileContent = fs.readFileSync(filePath, 'utf8').trim();
const fileContentArr = fileContent.split('\n');
if (/^\s*#\s*([^#].*?)\s*$/.test(fileContentArr[0])) fileContentArr.shift();
fileContent = fileContentArr.join('\n');
const HTMLContent = md.render(fileContent);
const TEXTContent = htmlToText.fromString(HTMLContent, {
wordwrap: false,
function readYaml(file, silent) {
try {
return YAML.safeLoad(fs.readFileSync(file, 'utf-8'), { filename: file });
} catch (e) {
if (!silent) {
console.log(chalk.red(e.message));
}
}
}
const loadConfig = function() {
let config = yaml.safeLoad(
fs.readFileSync(path.join(opts.root, '.stripe'), 'utf8')
)
if (!config.currency) config.currency = 'usd'
return config
}
'use strict';
const logger = require('../lib/logger');
const yaml = require('js-yaml');
const fs = require('fs');
const config = yaml.safeLoad(fs.readFileSync(__dirname + '/../../config.yml', 'utf8'));
const serverlessConfig = yaml.safeLoad(fs.readFileSync(__dirname + '/../../serverless.yml', 'utf8'));
const aws = require('../lib/aws')(config);
const lambda = aws.lambda;
const starterFunctionName = serverlessConfig.functions.starter.name
.replace('${self:service}', serverlessConfig.service)
.replace('${self:provider.stage}', serverlessConfig.provider.stage);
const deleteFunctionName = serverlessConfig.functions.delete.name
.replace('${self:service}', serverlessConfig.service)
.replace('${self:provider.stage}', serverlessConfig.provider.stage);
const Ajv = require('ajv');
const ajv = new Ajv();
const schema = require('./nstarter-schema.json');
const uuidV4 = require('uuid/v4');
module.exports.handler = (event, context, cb) => {
const actions = JSON.parse(event.body);
const valid = ajv.validate(schema, actions);
initializeBuildStateFromSettingsFile (state) {
try {
const { dir, name } = path.parse(state.getFilePath())
const filePath = path.format({ dir, name, ext: '.yaml' })
if (fs.existsSync(filePath)) {
const config = yaml.safeLoad(fs.readFileSync(filePath))
this.initializeBuildStateFromProperties(state, config)
}
} catch (error) {
latex.log.error(`Parsing of project file failed: ${error.message}`)
}
}
function loadFragment(buildOptions, smith, fragmentFileName) {
const fragmentsRoot = smith.path(buildOptions.contentFragments);
const fileLocation = path.join(fragmentsRoot, `${fragmentFileName}.yml`);
const fragmentFile = fs.readFileSync(fileLocation);
return yaml.safeLoad(fragmentFile);
}
private getProtocolItem = async (item: IProtocolItem) => {
const requestHeaders: HeadersInit = new Headers();
if (this.state.uriToken) {
requestHeaders.set(
"Authorization",
`Basic ${new Buffer(this.state.uriToken).toString("base64")}`,
);
}
try {
const res = await fetch(item.uri, {headers: requestHeaders});
const data = await res.text();
const protocol = yaml.safeLoad(data);
return {
name: protocol.name,
contributor: protocol.contributor,
description: protocol.description,
prerequisitesNum: protocol.prerequisites.length,
itemKey: item.name,
raw: data,
} as IProtocol;
} catch (err) {
return null;
}
}
}