Filesystem.writeJson()

Write some data to the specified destination path on disk.

Assumes file is encoded using utf8.

Usage

Hover over inputs/exits for more info.

var Filesystem = require('machinepack-fs');


// Write some data to the specified destination path on disk.

Filesystem.writeJson({

json: '*',

destination: '/Users/mikermcneil/.tmp/bar.json',

force: false,

}).exec({

// An unexpected error occurred.

error: function (err) {

 

},

// A file or folder already exists at the specified destination

alreadyExists: function () {

 

},

// OK.

success: function () {

 

},

});

Inputs

json required

The data to write to disk as JSON

'*'
destination required

Absolute path for the destination file (if relative path is provided, will resolve path from current working directory)

'/Users/mikermcneil/.tmp/bar.json'
force

Overwrite files or directories which might exist at or within the specified destination path?

false

Exits

error

An unexpected error occurred.

alreadyExists

A file or folder already exists at the specified destination

success

OK.