Sha256: 95d5328ff48a993a442dd537e362f5bc19ec60cd205683d3f401cc561d59615f

Contents?: true

Size: 657 Bytes

Versions: 48

Compression:

Stored size: 657 Bytes

Contents

'use strict'

const path = require('path')
const mkdir = require('../mkdirs')
const pathExists = require('../path-exists').pathExists
const jsonFile = require('./jsonfile')

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

  const dir = path.dirname(file)

  pathExists(dir, (err, itDoes) => {
    if (err) return callback(err)
    if (itDoes) return jsonFile.writeJson(file, data, options, callback)

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

module.exports = outputJson

Version data entries

48 entries across 48 versions & 3 rubygems

Version Path
boring_generators-0.5.0 tmp/templates/app_template/node_modules/fs-extra/lib/json/output-json.js
boring_generators-0.4.0 tmp/templates/app_template/node_modules/fs-extra/lib/json/output-json.js
ilog-0.4.1 node_modules/fs-extra/lib/json/output-json.js
ilog-0.4.0 node_modules/fs-extra/lib/json/output-json.js
ilog-0.3.3 node_modules/fs-extra/lib/json/output-json.js
govuk_publishing_components-18.0.0 node_modules/fs-extra/lib/json/output-json.js
govuk_publishing_components-17.21.0 node_modules/fs-extra/lib/json/output-json.js
govuk_publishing_components-17.20.0 node_modules/fs-extra/lib/json/output-json.js
govuk_publishing_components-17.19.1 node_modules/fs-extra/lib/json/output-json.js
govuk_publishing_components-17.19.0 node_modules/fs-extra/lib/json/output-json.js
govuk_publishing_components-17.18.0 node_modules/fs-extra/lib/json/output-json.js
govuk_publishing_components-17.17.0 node_modules/fs-extra/lib/json/output-json.js
govuk_publishing_components-17.16.0 node_modules/fs-extra/lib/json/output-json.js
govuk_publishing_components-17.15.0 node_modules/fs-extra/lib/json/output-json.js
govuk_publishing_components-17.14.0 node_modules/fs-extra/lib/json/output-json.js
govuk_publishing_components-17.13.0 node_modules/fs-extra/lib/json/output-json.js
govuk_publishing_components-17.12.2 node_modules/fs-extra/lib/json/output-json.js
govuk_publishing_components-17.12.1 node_modules/fs-extra/lib/json/output-json.js
govuk_publishing_components-17.12.0 node_modules/fs-extra/lib/json/output-json.js
govuk_publishing_components-17.11.0 node_modules/fs-extra/lib/json/output-json.js