output-json-sync.js 375 B

123456789101112131415161718
  1. 'use strict'
  2. const fs = require('graceful-fs')
  3. const path = require('path')
  4. const mkdir = require('../mkdirs')
  5. const jsonFile = require('./jsonfile')
  6. function outputJsonSync (file, data, options) {
  7. const dir = path.dirname(file)
  8. if (!fs.existsSync(dir)) {
  9. mkdir.mkdirsSync(dir)
  10. }
  11. jsonFile.writeJsonSync(file, data, options)
  12. }
  13. module.exports = outputJsonSync