From 3c51c3be85bb0d1bdb87ea0d6632f1c256912f27 Mon Sep 17 00:00:00 2001 From: Dimitri Staessens Date: Sun, 6 Oct 2019 21:37:45 +0200 Subject: build: Add some required modules for node --- node_modules/fs-extra/lib/json/output-json.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 node_modules/fs-extra/lib/json/output-json.js (limited to 'node_modules/fs-extra/lib/json/output-json.js') diff --git a/node_modules/fs-extra/lib/json/output-json.js b/node_modules/fs-extra/lib/json/output-json.js new file mode 100644 index 0000000..d45edb8 --- /dev/null +++ b/node_modules/fs-extra/lib/json/output-json.js @@ -0,0 +1,27 @@ +'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 -- cgit v1.2.3