source: trip-planner-front/node_modules/fs-extra/lib/json/output-json.js@ 6c1585f

Last change on this file since 6c1585f was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 657 bytes
RevLine 
[6a3a178]1'use strict'
2
3const path = require('path')
4const mkdir = require('../mkdirs')
5const pathExists = require('../path-exists').pathExists
6const jsonFile = require('./jsonfile')
7
8function outputJson (file, data, options, callback) {
9 if (typeof options === 'function') {
10 callback = options
11 options = {}
12 }
13
14 const dir = path.dirname(file)
15
16 pathExists(dir, (err, itDoes) => {
17 if (err) return callback(err)
18 if (itDoes) return jsonFile.writeJson(file, data, options, callback)
19
20 mkdir.mkdirs(dir, err => {
21 if (err) return callback(err)
22 jsonFile.writeJson(file, data, options, callback)
23 })
24 })
25}
26
27module.exports = outputJson
Note: See TracBrowser for help on using the repository browser.