本文整理汇总了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`);
}
示例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();
});
示例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;
}
}
示例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;
}
}
示例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];
示例6: yamlLoader
export async function yamlLoader(fileName): Promise<any> {
let loadedYaml: any = await asAwaitable( (cb) => fsExtra.readFile(fileName, 'utf8', cb))
return YAML.parse(loadedYaml)
}
示例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();
});
示例8: parse
public static parse(yaml: string): any {
return YAML.parse(yaml);
}
示例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'),