当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript js-yaml.safeDump函数代码示例

本文整理汇总了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);
    });
开发者ID:DarqueWarrior,项目名称:vsts-tasks,代码行数:26,代码来源:dockercomposeconfig.ts

示例2: serializeToYaml

export function serializeToYaml(object: object, skipInvalid = false, noRefs = false) {
  return safeDump(object, {
    lineWidth: 8000,
    skipInvalid,
    noRefs,
  })
}
开发者ID:electron-userland,项目名称:electron-builder,代码行数:7,代码来源:util.ts

示例3: buildYAML

export function buildYAML() {
	let yamlStr = '---\n';
	yamlStr += yaml.safeDump(JSONSource);

	return createStream(`${filename}.yaml`, yamlStr)
		.pipe(plumber())
		.pipe(gulp.dest('character-list'));
}
开发者ID:gluons,项目名称:Font-Awesome-Icon-Chars,代码行数:8,代码来源:gulpfile.ts

示例4:

 .then((): void => {
   fs.writeFile(path.resolve(name, 'monogatari', 'waka.yml'), yaml.safeDump(waka), err => {
     if(err) {
       throw err;
     }
     return;
   });
 })
开发者ID:waffle-iron,项目名称:shikibu,代码行数:8,代码来源:create.ts

示例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)}---`;
}
开发者ID:JoshuaKGoldberg,项目名称:tslint,代码行数:13,代码来源:buildDocs.ts

示例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);
  }
}
开发者ID:tyrchen,项目名称:clubhouse-cli,代码行数:10,代码来源:configuration.ts

示例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'));
}
开发者ID:gluons,项目名称:material-design-icon-chars,代码行数:10,代码来源:gulpfile.ts

示例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')
}
开发者ID:graphcool,项目名称:graphql-config,代码行数:10,代码来源:utils.ts

示例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()});
}
开发者ID:tuxtina,项目名称:json2yaml,代码行数:11,代码来源:extension.ts


注:本文中的js-yaml.safeDump函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。