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


TypeScript yamljs.parse函数代码示例

本文整理汇总了TypeScript中yamljs.parse函数的典型用法代码示例。如果您正苦于以下问题:TypeScript parse函数的具体用法?TypeScript parse怎么用?TypeScript parse使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了parse函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: backup

 public backup() {
     this.volumePrefix = DockerUtil.getContainerName(this.config.projectName);
     const composeFilePath = `${this.config.deployPath}/${this.config.projectName}/docker-compose.yml`;
     if (!existsSync(composeFilePath)) {
         return Log.error(`docker-compose.yml file does not exist at ${composeFilePath}`);
     }
     const composeConfig = YAML.parse(readFileSync(composeFilePath, { encoding: "utf8" }));
     const volumes = Object.keys(composeConfig.volumes);
     const services = Object.keys(composeConfig.services);
     const volumeDirectoryMap = {};
     for (let i = 0, il = services.length; i < il; ++i) {
         const service = composeConfig.services[services[i]];
         const serviceVolumes = service.volumes;
         for (let k = 0, kl = serviceVolumes.length; k < kl; ++k) {
             const volumeMap = serviceVolumes[k].split(":");
             volumeDirectoryMap[volumeMap[0]] = volumeMap[1];
         }
     }
     const volumeOption = [];
     const dirsToBackup = [];
     for (const volume in volumeDirectoryMap) {
         if (volumeDirectoryMap.hasOwnProperty(volume)) {
             if (!DockerUtil.isVolumeDriver(volume)) {
                 const volumeName = `${this.volumePrefix}_${volume}`;
                 volumeOption.push(`-v ${volumeName}:${volumeDirectoryMap[volume]}`);
             }
             dirsToBackup.push(volumeDirectoryMap[volume]);
         }
     }
     execute(`docker run ${volumeOption.join(" ")} --name ${this.backupName} busybox tar -cvf ${this.backupName}.tar ${dirsToBackup.join(" ")}`);
     execute(`docker cp ${this.backupName}:/${this.backupName}.tar ./${this.backupName}.tar`);
     execute(`docker rm -fv ${this.backupName}`);
     Log.info(`\n\nBackup was create to ${this.backupName}.tar`);
 }
开发者ID:VestaRayanAfzar,项目名称:vesta,代码行数:34,代码来源:Backuper.ts

示例2: expect

 request.get('http://localhost:5674/api-docs/yaml', (error, response, body) => {
     const swaggerDocument: any = YAML.parse(body);
     const expectedSwagger = _.cloneDeep(swaggerFile);
     expectedSwagger.host = 'localhost:5674';
     expectedSwagger.schemes = ["http"];
     expect(expectedSwagger).to.deep.equals(swaggerDocument);
     done();
 });
开发者ID:thiagobustamante,项目名称:typescript-rest,代码行数:8,代码来源:swagger.spec.ts

示例3: parse

private parse(sourceLanguage: SupportedLanguage, documentText: string): any {
    switch (sourceLanguage) {
        case "xml":
        case "tmlanguage":
            return plist.parse(documentText);
        case "json":
        case "json-tmlanguage":
            return JSON.parse(documentText);
        case "yaml":
        case "yaml-tmlanguage":
            return YAML.parse(documentText);
        default:
            return undefined;
    }
}
开发者ID:Togusa09,项目名称:vscode-tmlanguage,代码行数:15,代码来源:fileConverter.ts

示例4: function

                process: function(source, res) {
			
                    var YAML = require('yamljs')
        
                    source = source
                        .replace(/\t/g, '  ');
                        
        
                    try {
                        return YAML.parse(source);
                    } catch (error) {
                        logger.error('<yml parser>', error);
                        return null;
                    }
                }
开发者ID:atmajs,项目名称:atma-server,代码行数:15,代码来源:yml.ts

示例5: function

import * as YAML from 'yamljs';
import * as fs from 'fs-extra';
import * as path from 'path';

// First Copy the latest docs into the source directory
fs.emptyDirSync('source/');
fs.removeSync('pre-source/docs-production/.vscode/')
fs.copySync('pre-source/docs-production', 'source');


var _versions = YAML.parse(fs.readFileSync('./_config.yml', "utf8")).versions;
var versions: Array<string> = _versions.filter(e => e !== 'latest')
for (let version of versions) {
  console.log("Preparing Version: " + version);
  fs.copySync('pre-source/docs-' + version, 'source/' + version);
}

// Escape code blocks in the markdown
enumerate_child_files_recursive('source/', function (err, results) {
  if (err) throw err;
  for (let result of results) {
    var is_md = new RegExp(".md");
    if (is_md.test(result)) {
      fs.readFile(result, 'utf8', function (err, data) {
        if (err) {
          return console.log(err);
        }
        var backtick_positions = find(data, "```"); //find positions of backticks

        for (var i = 0, backtick_positions_1 = backtick_positions; i < backtick_positions_1.length; i++) {
          var backtick_position = backtick_positions_1[i];
开发者ID:georgeedwards,项目名称:docs,代码行数:31,代码来源:build.ts

示例6: yamlLoader

export async function yamlLoader(fileName): Promise<any> {
  let loadedYaml: any = await asAwaitable( (cb) => fsExtra.readFile(fileName, 'utf8', cb))
  return YAML.parse(loadedYaml)
}
开发者ID:tes,项目名称:resource-backup-tool,代码行数:4,代码来源:utils.ts

示例7: function

 request.get('http://localhost:5674/api-docs/yaml', function(error, response, body) {
     const swaggerDocument: any = YAML.parse(body);
     expect(swaggerDocument.basePath).to.eq('/v1');
     done();
 });
开发者ID:garyevari,项目名称:typescript-rest,代码行数:5,代码来源:test.spec.ts

示例8: parse

  public static parse(yaml: string): any {

    return YAML.parse(yaml);
  }
开发者ID:guedjm,项目名称:APIDocGenerator-pkg,代码行数:4,代码来源:yamlParser.ts

示例9: config

import { readFileSync as read } from 'fs';

import { pick_i18n } from '../strings';
import { EMAIL, PAYLOAD, CATEGORY } from './message';
import Message from './message';
import * as config from 'acm';

const ADDRESS_DO_NOT_REPLAY = config('email.addresses.do_not_reply');

const TEMPLATES = {
    base: template(asset('base.tmpl')),
    [EMAIL.WELCOME]: template(asset('welcome.tmpl')),
};

const ASSETS = {
    styles: parse(asset('styles.yml')),
    images: parse(asset('images.yml')),
};

const CONFIG: SmtpPoolOptions = {
    host: config('email.service.host'),
    maxConnections: config('email.smtp_pool.max_connections'),
    maxMessages: config('email.smtp_pool.max_messages'),
    auth: {
        user: config('email.service.user'),
        pass: config('email.service.pass'),
    },
};

const TEST_CONFIG: SmtpPoolOptions = {
    port: config('mock.smtp.smtp.port'),
开发者ID:consumr-project,项目名称:cp,代码行数:31,代码来源:email.ts


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