"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/fs-extra/lib/json/output-json.js" (8 Mar 2017, 585 Bytes) of archive /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Javascript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 var fs = require('graceful-fs')
    2 var path = require('path')
    3 var jsonFile = require('./jsonfile')
    4 var mkdir = require('../mkdirs')
    5 
    6 function outputJson (file, data, options, callback) {
    7   if (typeof options === 'function') {
    8     callback = options
    9     options = {}
   10   }
   11 
   12   var dir = path.dirname(file)
   13 
   14   fs.exists(dir, function (itDoes) {
   15     if (itDoes) return jsonFile.writeJson(file, data, options, callback)
   16 
   17     mkdir.mkdirs(dir, function (err) {
   18       if (err) return callback(err)
   19       jsonFile.writeJson(file, data, options, callback)
   20     })
   21   })
   22 }
   23 
   24 module.exports = outputJson