本文整理汇总了TypeScript中js-yaml.safeDump函数的典型用法代码示例。如果您正苦于以下问题:TypeScript safeDump函数的具体用法?TypeScript safeDump怎么用?TypeScript safeDump使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了safeDump函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: while
return connection.getCombinedConfig(imageDigestComposeFile).then(output => {
var removeBuildOptions = tl.getBoolInput("removeBuildOptions");
if (removeBuildOptions) {
var doc = yaml.safeLoad(output);
for (var serviceName in doc.services || {}) {
delete doc.services[serviceName].build;
}
output = yaml.safeDump(doc, {lineWidth: -1} as any);
}
var baseResolveDir = tl.getPathInput("baseResolveDirectory");
if (baseResolveDir) {
// This just searches the output string and replaces all
// occurrences of the base resolve directory. This isn't
// precisely accurate but is a good enough solution.
var replaced = output;
do {
output = replaced;
replaced = output.replace(baseResolveDir, ".");
} while (replaced !== output);
}
var outputDockerComposeFile = tl.getPathInput("outputDockerComposeFile", true);
fs.writeFileSync(outputDockerComposeFile, output);
});
示例2: serializeToYaml
export function serializeToYaml(object: object, skipInvalid = false, noRefs = false) {
return safeDump(object, {
lineWidth: 8000,
skipInvalid,
noRefs,
})
}
示例3: buildYAML
export function buildYAML() {
let yamlStr = '---\n';
yamlStr += yaml.safeDump(JSONSource);
return createStream(`${filename}.yaml`, yamlStr)
.pipe(plumber())
.pipe(gulp.dest('character-list'));
}
示例4:
.then((): void => {
fs.writeFile(path.resolve(name, 'monogatari', 'waka.yml'), yaml.safeDump(waka), err => {
if(err) {
throw err;
}
return;
});
})
示例5: generateFormatterFile
/**
* Based off a formatter's metadata, generates a Jekyll "HTML" file
* that only consists of a YAML front matter block.
*/
function generateFormatterFile(metadata: IFormatterMetadata): string {
const yamlData = generateJekyllData(
metadata,
"formatter",
"TSLint formatter",
metadata.formatterName,
);
return `---\n${yaml.safeDump(yamlData, { lineWidth: 140 } as any)}---`;
}
示例6: doFileSave
function doFileSave(fileName: string, config: IConfiguration): void {
try {
const configYml = yaml.safeDump({ "clubhouse-cli": config });
const dir = path.dirname(cfgFile);
if (!fs.existsSync(dir)) fs.mkdirSync(dir);
fs.writeFileSync(fileName, configYml, { flag: 'w' });
} catch (e) {
console.error(e.message);
}
}
示例7: buildYAML
export async function buildYAML() {
const iconSource = await getSource();
return createStream(
'character-list.yaml',
`---\n${yaml.safeDump(iconSource)}`
)
.pipe(plumber())
.pipe(dest('character-list'));
}
示例8: writeConfig
export function writeConfig(configPath: string, config: GraphQLConfigData) {
let configContents
if (configPath.endsWith('.yaml') || configPath.endsWith('.yml')) {
configContents = yaml.safeDump(config)
} else {
configContents = JSON.stringify(config)
}
writeFileSync(configPath, configContents, 'utf-8')
}
示例9: toYAML
export function toYAML(text) {
let json;
try {
json = JSON.parse(text);
} catch (e) {
vscode.window.showErrorMessage('Could not parse the selection as JSON.');
console.error(e);
return;
}
return yaml.safeDump(json, {indent: getIndent()});
}