本文整理汇总了TypeScript中js-yaml.load函数的典型用法代码示例。如果您正苦于以下问题:TypeScript load函数的具体用法?TypeScript load怎么用?TypeScript load使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了load函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor(configDir: string, cb: Function) {
const serverConfigpath: string = path.join(configDir, 'serverConfig.yml');
this.serverConfig = yaml.load(fs.readFileSync(serverConfigpath, 'utf8'));
const renderRulesPath: string = path.join(configDir, 'serverRenderRules.yml');
this.renderRules = Validators.unserializeServerRules(yaml.load(fs.readFileSync(renderRulesPath, 'utf8')));
const cacheRulesPath: string = path.join(configDir, 'serverCacheRules.yml');
this.cacheRules = CacheEngineCB.helpers.unserializeCacheRules(yaml.load(fs.readFileSync(cacheRulesPath, 'utf8')));
CacheCreator.createCache('SERVER', true, this.serverConfig.redisConfig, this.cacheRules, (err) => {
if (err) {
debug('Some error: ', err);
const error = new Error(err);
this.logger.error(error);
return cb(err);
}
UrlCache.loadCacheEngine(this.serverConfig.domain, 'SERVER', this.serverConfig.redisConfig, (err) => {
if(err) {
const error = new Error(err);
this.logger.error(error);
return cb(err);
}
cb(null);
});
});
}
开发者ID:a-lucas,项目名称:angular.js-server,代码行数:29,代码来源:cache.ts
示例2: function
(async function () {
const fontsYAML = await readFile('src/fonts/fonts.yml')
const enFontsYAML = await readFile('src/fonts/fonts.en.yml')
const fonts = yaml.load(fontsYAML) as Font[]
const enFonts = yaml.load(enFontsYAML) as Font[]
const results = new Parser(fonts, enFonts).parse()
const writeFile = promisify(fs.writeFile);
for (let fn of [css, less, scss, styl]) {
await writeFile("dist/fonts." + fn.name, results.map(fn).join("\n"))
}
})()
开发者ID:praycis-lee,项目名称:fonts.css,代码行数:11,代码来源:build.ts
示例3: getDocMetadata
function getDocMetadata(tree) {
if (tree.children[0].type == "yaml") {
return yaml.load(tree.children[0].value);
} else {
return {};
}
}
开发者ID:Alfresco,项目名称:alfresco-ng2-components,代码行数:7,代码来源:tutorialIndex.ts
示例4: constructor
constructor(private configDir:string) {
debug('DIRNAME = ', __dirname);
if (!fs.existsSync(configDir)) {
throw `The config dir doesn't exists ${configDir}`;
}
let configPath:string;
['serverConfig.yml', 'serverRenderRules.yml', 'serverCacheRules.yml', 'slimerRestCacheRules.yml'].forEach((item) => {
configPath = path.join(configDir, item);
if (!fs.existsSync(configPath)) {
throw new Error('The config file ' + configPath + ' doesnt exists');
}
//check file validity
yaml.load(fs.readFileSync(configPath, 'utf8'));
});
//todo check every config file syntax
this.serverConfig = yaml.load(fs.readFileSync( path.join(this.configDir, 'serverConfig.yml') , 'utf8'));
debug('serverConfig ', this.serverConfig);
ServerLog.initLogs(this.serverConfig.logBasePath, this.serverConfig.gelf);
ServerLog.Log.info('Master starting');
}
开发者ID:a-lucas,项目名称:angular.js-server,代码行数:26,代码来源:masterProcess.ts
示例5: postGenerator
export async function postGenerator() {
console.log("\n😳 😳 🤖 😳 LET'S MAKE A BLOG POST! 😳 😳 🤖 😳 \n")
const config = load(fs.readFileSync("./blog.config.yml", "utf8")) || {}
const { author = "", title = "" } = await prompt([
q.postTitle,
{ ...q.postAuthor, default: config.author || "" },
]) as IPost
const id = title
.replace(",", "")
.replace(/[^a-zA-Z0-9_.@()-]/g, "-")
.toLowerCase()
const permalink = join("posts", `${id}.md`)
const now = new Date()
const postData = { author, id, permalink, title, created: now, updated: now }
const frontmatter = `---\n${dump(postData)}---\n`
await writeFile(permalink, frontmatter + `# ${title}\n`)
console.log(`
Congratulations! 🎉 🎉 🎉
You generated a blog post!
`)
}
开发者ID:Blanket-Warriors,项目名称:Blog-O-Matic,代码行数:26,代码来源:postGenerator.ts
示例6: parse
async function parse(previewDir: string, name: string) {
const unparsed = await readFile(resolve(previewDir, "posts", name))
const parsed = /(?:^---\n)([\s\S]*)(?:---\n)(([\s\S])*)/gm.exec(unparsed) || []
const hasFrontmatter = parsed.length
const text = (hasFrontmatter ? parsed[2] : unparsed)
const metadata = load(parsed[1])
return [ metadata, text ]
}
开发者ID:Blanket-Warriors,项目名称:Blog-O-Matic,代码行数:8,代码来源:index.ts
示例7: Error
['serverConfig.yml', 'serverRenderRules.yml', 'serverCacheRules.yml', 'slimerRestCacheRules.yml'].forEach((item) => {
configPath = path.join(configDir, item);
if (!fs.existsSync(configPath)) {
throw new Error('The config file ' + configPath + ' doesnt exists');
}
//check file validity
yaml.load(fs.readFileSync(configPath, 'utf8'));
});
开发者ID:a-lucas,项目名称:angular.js-server,代码行数:8,代码来源:masterProcess.ts
示例8: constructor
constructor(private configDir: string) {
const serverConfigpath: string = path.join(configDir, 'serverConfig.yml');
this.serverConfig = yaml.load(fs.readFileSync(serverConfigpath, 'utf8'));
Bridge_Pool.init(this.serverConfig);
ServerLog.initLogs(this.serverConfig.logBasePath, this.serverConfig.gelf);
}
开发者ID:a-lucas,项目名称:angular.js-server,代码行数:9,代码来源:bridge.ts
示例9: validate
public validate(variable: IVariable, errors: IVariableError[]): void {
if (!variable.value) {
errors.push({ message: 'Field is required.' });
}
try {
load(variable.value);
} catch (e) {
errors.push({ message: e.message });
}
}
开发者ID:robfletcher,项目名称:deck,代码行数:10,代码来源:object.validator.ts
示例10: getSecrets
function getSecrets(cwd: string) {
const localSecretsPath = path.join(cwd, secretsFile)
let secrets = {}
if (fs.existsSync(localSecretsPath)) {
secrets = YAML.load(fs.readFileSync(localSecretsPath).toString())
}
return secrets
}
开发者ID:dianpeng,项目名称:fly,代码行数:10,代码来源:file_app_store.ts
示例11: get_config
function get_config(program: Program) { // tslint:disable-line no-shadowed-variable
try {
if (program.configContent) {
return jsyaml.load(program.configContent) as Xlsx2SeedSheetConfig;
} else {
if (program.config) {
return jsyaml.load(fs.readFileSync(program.config, {encoding: 'utf8'})) as Xlsx2SeedSheetConfig;
} else if (fs.existsSync(default_config_file)) {
return jsyaml.load(fs.readFileSync(default_config_file, {encoding: 'utf8'})) as Xlsx2SeedSheetConfig;
} else {
return {};
}
}
} catch (error) {
console.error('load config failed!');
console.error(error.toString());
process.exit(1);
throw error;
}
}
开发者ID:Narazaka,项目名称:xlsx2seed.js,代码行数:20,代码来源:xlsx2seed.ts
示例12: parse
function parse (body:string) {
if (body.length === 0) {
// special-case empty yaml body, as it's a common client-side mistake
// TODO: maybe make this configurable or part of "strict" option
return {}
}
debug('parse yaml');
let result = yamlParser.load(body);
return result;
}
开发者ID:MaxxtonGroup,项目名称:microdocs,代码行数:11,代码来源:yaml-parser.ts
示例13: async
const main = async (dir: string) => {
try {
const list = fs.recursiveReaddir(dir)
for await (const file of list) {
const f = path.parse(file)
if (f.base === "readme.md") {
console.log(`processing ${file}`)
const content = (await fs.readFile(file)).toString()
const readMe = cm.parse(content)
const set = new Set<string>()
for (const c of cm.iterate(readMe.markDown)) {
if (
c.type === "code_block" &&
c.info !== null &&
c.info.startsWith("yaml") &&
c.literal !== null
) {
const y = (yaml.load(c.literal) as Code)["input-file"]
if (typeof y === "string") {
set.add(y)
} else if (it.isArray(y)) {
for (const i of y) {
set.add(i)
}
}
}
}
const readMeMulti = cm.createNode(
"document",
cm.createNode(
"heading",
cm.createText("Multi-API support for AutoRest v3 generators")
),
cm.createNode(
"block_quote",
cm.createNode(
"paragraph",
cm.createText("see https://aka.ms/autorest")
)
),
cm.createCodeBlock(
"yaml $(enable-multi-api)",
yaml.dump({ "input-file": it.toArray(set) }, { lineWidth: 1000 })
)
)
const x = cm.markDownExToString({ markDown: readMeMulti })
fs.writeFile(path.join(f.dir, "readme.enable-multi-api.md"), x)
}
}
} catch (e) {
console.error(e)
}
}
开发者ID:Nking92,项目名称:azure-rest-api-specs,代码行数:53,代码来源:multiapi.ts
示例14: load
['', "traffic.spinnaker.io/load-balancers: '[]'"].forEach(annotation => {
const canDisable = ManifestTrafficService.canDisableServerGroup({
disabled: false,
serverGroupManagers: [],
manifest: load(`
kind: ReplicaSet
metadata:
annotations:
${annotation}
`),
} as any);
expect(canDisable).toEqual(false);
});
开发者ID:emjburns,项目名称:deck,代码行数:13,代码来源:ManifestTrafficService.spec.ts
示例15: it
it('will not disable an already disabled server group', () => {
const canDisable = ManifestTrafficService.canDisableServerGroup({
disabled: true,
serverGroupManagers: [],
manifest: load(`
kind: ReplicaSet
metadata:
annotations:
traffic.spinnaker.io/load-balancers: '[\"service my-service\"]'
`),
} as any);
expect(canDisable).toEqual(false);
});
开发者ID:emjburns,项目名称:deck,代码行数:13,代码来源:ManifestTrafficService.spec.ts
示例16: join
return new Promise<Config>((resolve, reject) => {
const config_dir = app.getPath('userData');
const file = join(config_dir, 'config.yml');
try {
this.user_config = loadYAML(readFileSync(file, {encoding: 'utf8'})) as Config;
mergeConfig(this.user_config, default_config);
} catch (e) {
console.log('No configuration file was found: ' + file);
this.user_config = default_config;
}
this.user_config._config_dir_path = config_dir;
resolve(this.user_config);
});
开发者ID:WondermSwift,项目名称:Shiba,代码行数:15,代码来源:config.ts
示例17: getDocReviewDate
function getDocReviewDate(docFileName) {
let mdFilePath = path.resolve(docsFolderPath, docFileName);
let mdText = fs.readFileSync(mdFilePath);
let tree = remark().use(frontMatter, ["yaml"]).parse(mdText);
let lastReviewDate = moment(adf20StartDate);
if (tree.children[0].type == "yaml") {
let metadata = yaml.load(tree.children[0].value);
if (metadata["Last reviewed"])
lastReviewDate = moment(metadata["Last reviewed"]);
}
return lastReviewDate;
}
开发者ID:Alfresco,项目名称:alfresco-ng2-components,代码行数:17,代码来源:reviewChecker.ts
示例18: buildConfig
function buildConfig(sourceDir: string, buildDir: string, env: string) {
const sourceFile = path.join(sourceDir, configFile)
const outFile = path.join(buildDir, configFileOutput)
let config: any = {}
if (fs.existsSync(sourceFile)) {
const inputConfig = YAML.load(fs.readFileSync(sourceFile).toString()) || {}
config = inputConfig[env] || inputConfig || {}
}
config.app = config.app_id || config.app || sourceDir
config.files = expandFiles(sourceDir, config.files || [])
config.config = config.config || {}
fs.writeFileSync(outFile, YAML.dump(config))
return config
}
开发者ID:dianpeng,项目名称:fly,代码行数:19,代码来源:file_app_store.ts
示例19: start
function start(command = argv._[0]) {
if (command === "init") return blogGenerator()
const cwd = process.cwd()
const configPath = resolve(cwd, "blog.config.yml")
if (!existsSync(configPath)) throw new Error("This is not a blog! Please go to the dir where blog.config.yml exists.")
const config = load(readFileSync(resolve(configPath), "utf8")) || {}
const publisher = config.publisher
if (command === "post") postGenerator()
else if (command === "preview") preview(cwd)
else if (command === "publish") {
if (!argv.s3 && !argv.fs) {
if (publisher === "s3") s3Publisher(cwd, config)
if (publisher === "fs") fsPublisher(cwd, config)
} else {
if (argv.s3) s3Publisher(cwd, config)
if (argv.fs) fsPublisher(cwd, config)
}
} else console.log(helpText)
}
开发者ID:Blanket-Warriors,项目名称:Blog-O-Matic,代码行数:21,代码来源:index.ts
示例20: start
start(cb: Function) {
const slimerRestCacheModulePath = path.join(this.configDir, 'slimerRestCacheRules.yml');
const cacheRules = {
Slimer_Rest: CacheEngineCB.helpers.unserializeCacheRules(yaml.load(fs.readFileSync(slimerRestCacheModulePath, 'utf8')))
};
let parrallelFns = {};
for(var key in cacheRules) {
parrallelFns[key] = (cb) => {
CacheCreator.createCache(key.toUpperCase(), true, this.serverConfig.redisConfig, cacheRules[key], (err) => {
if (err) return cb(err);
cb(null);
});
};
}
debug('Starting');
async.parallel(parrallelFns, (err) => {
if( err) {
return cb(err);
//this.serverLog.log('server', ["Error creating cache for", cacheData.t], {rules: cacheData.r, err: err, instance: cacheData.t});
} else {
this.bridge = new Bridge(this.configDir);
this.bridge.start( (err) => {
if(err) return cb(err);
this.launchCDNServer( (err) => {
if(err) return cb(err);
cb();
});
});
}
}
);
}
开发者ID:a-lucas,项目名称:angular.js-server,代码行数:37,代码来源:masterProcess.ts
注:本文中的js-yaml.load函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论