How to use the outputJson function from fs-extra

Find comprehensive JavaScript fs-extra.outputJson code examples handpicked from public code repositorys.

438
439
440
441
442
443
444
445
446
447
 * Helper function for addDefaultLayoutToSiteConfig().
 */
static async writeToSiteConfig(config, configPath) {
  const layoutObj = { glob: '**/*.md', layout: LAYOUT_DEFAULT_NAME };
  config.pages.push(layoutObj);
  await fs.outputJson(configPath, config);
}

static printBaseUrlMessage() {
  logger.info('The default base URL of your site is set to /\n'
fork icon106
star icon94
watch icon13

+ 3 other calls in file

26
27
28
29
30
31
32
33
34
console.log(`Initialising '${dir}'...`);
console.log(`Database engine: '${dbengine}'`);

// dynamic files
const databaseConfig = join(cwd, dir, 'config', 'database.json');
await fs.outputJson(databaseConfig, generateDatabaseConfig(name), { spaces: 2 });

const packageJSON = join(cwd, dir, 'package.json');
await fs.outputJson(packageJSON, generatePackageJSON(dir, dbengine), { spaces: 2 });
fork icon36
star icon0
watch icon2

+ 3 other calls in file

174
175
176
177
178
179
180
181
182
    return
  }

  // save updated cache to filesystem
  cache[src] = dimensions
  return fse.outputJson(config.files.imageCache, cache)
})
.then(() => {
  addingImgToCache = false
fork icon1
star icon16
watch icon9

15
16
17
18
19
20
21
22
23
24
try {
    const fs = require('fs-extra');
    let file = this.json_file_src;
    fs.remove(file).then(() => {
        // 创建json并写入初始化json数据
        fs.outputJson(file, {...init_json}).then(r => {
            resolve(true)
        })
    })
} catch (e) {
fork icon0
star icon1
watch icon1

+ 1109 other calls in file

42
43
44
45
46
47
48
49
50
51
    print(chalk.yellow('Warning: no changes detected. Save cancelled.'))
  } else {
    await _writeToDisk()
    const [head, version] = [po.head, po.version]
    await mod.metaOps.update(head, version, mdata)
    await fs.outputJson(mod.muOps.path('history', head, 'v' + version + '.json'), diff.currentTree)
    await po.incrementVersion()
    print(chalk.green(`${head} v${version} successfully saved!`))
  }
}
fork icon0
star icon1
watch icon0

248
249
250
251
252
253
254
255
256
257
258
259
];


var fallbackVersion = { minor: '9201', symbol: 'Uo', element: 'Unobtainium' };


async function run() {
  outputJson(OUTPUT_PATH, await getReleases(), { spaces: 2 });
}


run();
fork icon0
star icon0
watch icon1

+ 15 other calls in file

268
269
270
271
272
273
274
   /**
    * write critical initialize error into a single file. workerpool has a problem with emit
    * of this errors - all of this errors emits with message "Worker terminated unexpectedly"
    * without any message about what's exactly happened inside worker that cause process exit.
    */
   fs.outputJson(path.join(process.env.logsPath, `worker/worker-initialize-error-${process.pid}.json`), error);
}
fork icon0
star icon0
watch icon0

+ 3 other calls in file

function icon

fs-extra.readFileSync is the most popular function in fs-extra (9724 examples)