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