Filesystem.write()

Generate a file on the local filesystem using the specified utf8 string as its contents.

Usage

Hover over inputs/exits for more info.

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


// Generate a file on the local filesystem using the specified utf8 string as its contents.

Filesystem.write({

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

string: 'lots of words, utf8 things you know',

force: false,

}).exec({

// An unexpected error occurred.

error: function (err) {

 

},

// Something already exists at the specified path (overwrite by enabling the `force` input)

alreadyExists: function () {

 

},

// OK.

success: function () {

 

},

});

Inputs

destination required

Path (relative or absolute) to the file to write.

'/Users/mikermcneil/.tmp/bar'
string

Text to write to the file (if omitted, will create an empty file)

'lots of words, utf8 things you know'
force

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

false

Exits

error

An unexpected error occurred.

alreadyExists

Something already exists at the specified path (overwrite by enabling the `force` input)

success

OK.