Skip to content

Commit

Permalink
Refactor outputJson
Browse files Browse the repository at this point in the history
  • Loading branch information
JPeer264 committed Feb 17, 2017
1 parent 6f69cd6 commit 4a9db4e
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/json/output-json.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
var fs = require('graceful-fs')
var path = require('path')
var jsonFile = require('./jsonfile')
var mkdir = require('../mkdirs')
'use strict'

const fs = require('graceful-fs')
const path = require('path')
const mkdir = require('../mkdirs')
const jsonFile = require('./jsonfile')

function outputJson (file, data, options, callback) {
if (typeof options === 'function') {
callback = options
options = {}
}

var dir = path.dirname(file)
const dir = path.dirname(file)

fs.exists(dir, function (itDoes) {
fs.exists(dir, itDoes => {
if (itDoes) return jsonFile.writeJson(file, data, options, callback)

mkdir.mkdirs(dir, function (err) {
mkdir.mkdirs(dir, err => {
if (err) return callback(err)
jsonFile.writeJson(file, data, options, callback)
})
Expand Down

0 comments on commit 4a9db4e

Please sign in to comment.