本文整理汇总了TypeScript中fs-extra-promise.outputFileAsync函数的典型用法代码示例。如果您正苦于以下问题:TypeScript outputFileAsync函数的具体用法?TypeScript outputFileAsync怎么用?TypeScript outputFileAsync使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了outputFileAsync函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: writeTranslation
function writeTranslation(translation: ParsedTranslation) {
const filename = join(project.ws.srcDir, project.ws.i18n.dir, `${translation.locale}.js`);
const data = `${GENERATED_WARNING}
module.exports.asts = ${JSON.stringify(translation.asts, null, ' ')};`;
return outputFileAsync(filename, data);
}
开发者ID:Mercateo,项目名称:typedocs,代码行数:7,代码来源:i18n-compile.ts
示例2: resolve
res.on('end', () => {
if (IGNORED_CONTENTS.some((content) => body === content)) {
resolve();
} else {
outputFileAsync(outputPath, body).then(() => resolve()).catch(reject);
}
});
开发者ID:Mercateo,项目名称:typedocs,代码行数:7,代码来源:i18n-import.ts
示例3: write_file
export async function write_file(file_path: string, data: string): Promise<void>{
await lock.acquire();
try{
await fs.outputFileAsync(file_path, data);
}
finally{
lock.release();
}
}
开发者ID:BelaPlatform,项目名称:Bela,代码行数:9,代码来源:FileManager.ts
示例4: writeTranslation
async function writeTranslation(
defaultTranslation: ParsedTranslation,
translation: ParsedTranslation
) {
const filename = join(project.ws.i18n!.distDir, `${translation.locale}.js`);
const keys = Object.keys(defaultTranslation.data);
const intlLocale = await toIntlLocale(translation.locale);
const data = `${GENERATED_WARNING}
var IntlMessageFormat = require('intl-messageformat');
// use intl polyfill for IE 10 and Safari 9
require('intl');
require('intl/locale-data/jsonp/${intlLocale}');
module.exports.LOCALE = '${translation.locale}';
module.exports.INTL_LOCALE = '${intlLocale}';
module.exports.LANGUAGE_CODE = '${translation.locale.split('_')[0]}';
module.exports.COUNTRY_CODE = '${translation.locale.split('_')[1]}';
var cachedMessages = {};
${keys
.map(
(key) => `
module.exports['${key}'] = function(${
hasArguments(translation.asts[key]) ? 'data' : ''
}) {${
translation.asts[key]
? `
if (!cachedMessages['${key}']) {
var ast = ${indent(
' ',
stringifyObject(translation.asts[key], stringifyObjectOptions)
)};
cachedMessages['${key}'] = new IntlMessageFormat(ast, '${intlLocale}');
}
return cachedMessages['${key}'].format(${
hasArguments(translation.asts[key]) ? 'data' : ''
});`
: `return 'Missing key "${key}".';`
}
};
`
)
.join('')}
`;
return outputFileAsync(filename, data);
}
开发者ID:Mercateo,项目名称:ws,代码行数:49,代码来源:compile.ts
示例5: writeDeclaration
function writeDeclaration(translations: ParsedTranslation[]) {
const filename = join(project.ws.i18n!.distDir, 'index.d.ts');
const defaultTranslation = translations[0];
const keys = Object.keys(defaultTranslation.data);
const data = `${GENERATED_WARNING}
declare interface I18N {
/**
* Your locale in the format \`de_DE\`, \`en_US\`, etc.
*/
LOCALE: string;
/**
* Your locale in the format \`de-DE\`, \`en-US\`, etc.
*/
INTL_LOCALE: string;
/**
* Your language code in the format \`de\`, \`en\`, etc.
*/
LANGUAGE_CODE: string;
/**
* Your country code in the format \`DE\`, \`US\`, etc.
*/
COUNTRY_CODE: string;${keys
.map(
(key) =>
`
${getDocumentation(translations, key)}
${key}: (${
hasArguments(defaultTranslation.asts[key])
? `data: ${getArgumentTypes(defaultTranslation.asts[key])}`
: ''
}) => string,`
)
.join('\n')}
}
`;
return outputFileAsync(filename, data);
}
开发者ID:Mercateo,项目名称:ws,代码行数:42,代码来源:compile.ts
示例6: writeIndexTranslation
function writeIndexTranslation(translations: ParsedTranslation[]) {
const filename = join(project.ws.srcDir, project.ws.i18n.dir, `index.${project.ws.entryExtension}`);
const hasTypes = project.ws.entryExtension !== 'js';
const data =
`${GENERATED_WARNING}
const INTL_LOCALE = process.env.LOCALE.replace('_', '-');
const asts = require(\`./\${process.env.LOCALE}\`).asts;
const IntlMessageFormat = require('intl-messageformat');
const lazyMessages = {};${Object.keys(translations[0].data).map(key => `
${getDocumentation(translations, key)}
export const ${key} = (${hasArguments(translations[0].asts[key]) ? `data${hasTypes ? `: ${getArguments(translations[0].asts[key])}` : ''}` : ''})${hasTypes ? ': string' : ''} => {
if (!lazyMessages['${key}']) {
lazyMessages['${key}'] = new IntlMessageFormat(asts['${key}'], INTL_LOCALE);
}
return lazyMessages['${key}'].format(${hasArguments(translations[0].asts[key]) ? 'data' : ''});
};`
).join('')}
`;
return outputFileAsync(filename, data);
}
开发者ID:Mercateo,项目名称:typedocs,代码行数:23,代码来源:i18n-compile.ts
注:本文中的fs-extra-promise.outputFileAsync函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论