當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。