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) {

 

},

// An existing file or folder was found at the specified destination. Use `force` to overwrite.

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

An existing file or folder was found at the specified destination. Use `force` to overwrite.

success

OK.