Filesystem.writeSync()

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

Encodes file contents as utf8. This machine should **NEVER** be used in request handling code!

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.writeSync({

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

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

force: false,

}).execSync();

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

Whether to overwrite existing file(s) which might exist at the destination path.

false

Exits

error

An unexpected error occurred.

alreadyExists

An existing file / folder was found at the specified path (overwrite by enabling the `force` input).

success

OK.