本文整理匯總了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()});
}