Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function main() {
try {
// Load module files
const payload = await readFile(MODULES_PATH, { encoding: "utf8" });
// Parse yaml payload
const modules = yaml.safeLoad(payload, "utf8");
// Transform into site acceptable format
const siteModules = await transform(modules);
// Store new file
await writeFile(
SITE_MODULES,
yaml.safeDump(siteModules, { lineWidth: 500 })
);
} catch (error) {
console.log(error);
process.exit(1);
}
}
function updateConfigKey( options, cb ) {
var configFile = Matrix.config.path.apps + '/' + options.name + '.matrix/config.yaml';
var config = yaml.loadSafe( fs.readFileSync( configFile ) );
if ( config.hasOwnProperty( 'configuration' ) ) {
//FIXME: Depreciate this path
console.warn( '`configuration` in app config', options );
config.configuration[ options.key ] = options.value;
} else {
// this is the newness
config.settings[ options.key ] = options.value;
}
var configJs = yaml.safeDump( config );
fs.writeFile( configFile, configJs, cb );
}
return;
}
const template = yaml.safeLoad(resourceYaml);
templatise(template);
// TODO: offer a default
const templateName = await context.host.showInputBox({ prompt: "Name for the new template" });
if (!templateName) {
return;
}
const templateFile = path.join(chart.path, "templates", templateName + ".yaml");
// TODO: check if file already exists
const templateYaml = yaml.safeDump(template); // the parse-dump cycle can change the indentation of collections - is this an issue?
const templateText = fixYamlValueQuoting(templateYaml);
context.fs.writeFileSync(templateFile, templateText);
await context.host.showDocument(vscode.Uri.file(templateFile));
}
var write_cloud_config_from_object = function (data, output_file) {
try {
fs.writeFileSync(output_file, [
'#cloud-config',
yaml.safeDump(data),
].join("\n"));
return output_file;
} catch (e) {
console.log(colors.red(e));
}
};
export function getPrintableDetails(item: any, indent: number) {
const details = jsyaml.safeDump(item, {
indent: 4,
lineWidth: -1,
skipInvalid: true
});
return details.split('\n').map(line => new Array(indent).join(' ') + line).join('\n');
}
_(states).each(function(state, key) {
fs.writeFile(path.join(dir, key + '.yaml'), yaml.safeDump(state));
console.log('Exported ' + path.join(dir, key + '.yaml'));
});
})
function dumpYAMLConfig(packageJsonPath, scripts) {
const packageScriptsPath = resolve(
dirname(packageJsonPath),
'./package-scripts.yml',
)
const fileContents = safeDump({scripts: structureScripts(scripts)})
writeFileSync(packageScriptsPath, fileContents)
return {packageJsonPath, packageScriptsPath}
}
inspect({ req, res }) {
let model = {
name: this.name(),
module: this.module(),
api: this.api(),
req: req || {},
res: res || {}
}
return yaml.safeDump(model)
}
return tokens.reduce((combined, token) => {
if (token.type === 'code' && token.text.length > 0) {
if (token.lang === 'json') {
return combined += `${yaml.safeDump(JSON.parse(token.text), { noRefs: true })}\n`
}
if (token.lang === 'yaml') {
return combined += `${token.text}\n`
}
}
return combined
}, '')
} catch (error) {
properties[name] = this[name];
hasChanged = true;
} else if (properties[name]) {
delete properties[name];
hasChanged = true;
}
}
});
if (hasChanged) {
if (Object.keys(extensions).length) {
properties.extensions = extensions;
} else {
delete properties.extensions;
}
this.setYamlProperties(Object.keys(properties).length
? yaml.safeDump(properties)
: '\n');
}
},
setSimpleTab() {