本文整理汇总了TypeScript中fs-extra.outputJson函数的典型用法代码示例。如果您正苦于以下问题:TypeScript outputJson函数的具体用法?TypeScript outputJson怎么用?TypeScript outputJson使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了outputJson函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: next
gulp.task('settings:reset', (next) => {
const s = JSON.parse(JSON.stringify(settings));
s.env = 'dev';
s.mock = false;
fs.outputJson('./src/assets/settings.json', s, { spaces: 4 })
.then(() => next());
});
示例2: mergeJSON
gulp.task('settings:update', (next) => {
const s = JSON.parse(JSON.stringify(settings));
mergeJSON(s, prod_settings);
s.mock = !!argv.mock || (argv.demo && argv.demo !== 'false');
s.env = !!argv.prod ? 'prod' : 'dev';
fs.outputJson('./src/assets/settings.json', s, { spaces: 4 })
.then(() => next());
});
示例3: Boolean
Object.keys(availableLanguages).map(async (availableLanguage) => {
const messagesJsonStr = await transifex.translationInstanceMethodAsync(
projectSlug,
resourceSlug,
availableLanguage,
{mode: 'onlytranslated'}
)
const messagesJson: Messages = JSON.parse(messagesJsonStr)
const sortedMessagesJson = Object.keys(messagesJson)
.filter((key) => Boolean(R.path([key, 'message'], messagesJson)))
.sort()
.reduce((obj: Messages, key) => {
// trim message
if (messagesJson[key].message) {
messagesJson[key].message = messagesJson[key].message.trim()
}
return {
...obj,
[key]: messagesJson[key]
}
}, {})
let mappedLanguage = ''
switch (availableLanguage) {
case 'nb_NO':
mappedLanguage = 'nb'
break
default:
mappedLanguage = availableLanguage
}
await fs.mkdirs(path.join(localesPath, mappedLanguage))
await fs.outputJson(
path.join(localesPath, mappedLanguage, 'messages.json'),
sortedMessagesJson,
{spaces: 2}
)
console.log(`"${mappedLanguage}" is generated`)
})
示例4:
fs.mkdirp(dir).then(() => {
// stub
});
fs.mkdirs(dir, errorCallback);
fs.mkdirsSync(dir);
fs.mkdirp(dir, errorCallback);
fs.mkdirpSync(dir);
fs.outputFile(file, data).then(() => {
// stub
});
fs.outputFile(file, data, errorCallback);
fs.outputFileSync(file, data);
fs.outputJson(file, data, {
spaces: 2
}).then(() => {
// stub
});
fs.outputJson(file, data, {
spaces: 2
}, errorCallback);
fs.outputJSON(file, data, errorCallback);
fs.outputJSON(file, data).then(() => {
// stub
});
fs.outputJsonSync(file, data);
fs.outputJSONSync(file, data);
fs.readJson(file).then(() => {
示例5:
);
fs.createFile(file, errorCallback);
fs.createFileSync(file);
fs.mkdirs(dir, errorCallback);
fs.mkdirs(dir, {}, errorCallback);
fs.mkdirsSync(dir);
fs.mkdirsSync(dir, {});
fs.mkdirp(dir, errorCallback);
fs.mkdirp(dir, {}, errorCallback);
fs.mkdirpSync(dir);
fs.mkdirpSync(dir, {});
fs.outputFile(file, data, errorCallback);
fs.outputFileSync(file, data);
fs.outputJson(file, data, errorCallback);
fs.outputJSON(file, data, errorCallback);
fs.outputJsonSync(file, data);
fs.outputJSONSync(file, data);
fs.readJson(file, (error: Error, jsonObject: any) => {});
fs.readJson(file, readOptions, (error: Error, jsonObject: any) => {});
fs.readJSON(file, (error: Error, jsonObject: any) => {});
fs.readJSON(file, readOptions, (error: Error, jsonObject: any) => {});
fs.readJsonSync(file, readOptions);
fs.readJSONSync(file, readOptions);
fs.remove(dir, errorCallback);
fs.removeSync(dir);
示例6:
return Promise.resolve().then(() => fs.outputJson(filename, value, { spaces: "\t", EOL: "\r\n", replacer } as any));
示例7: Promise
return new Promise((resolve, reject) => {
fs.outputJson(dirHelper("notes.noam"), newData, function(err) {
if (err) reject(err);
resolve();
});
});