FileWriter Class
a concrete writer implementation that can write files synchronously or asynchronously based on the constructor argument passed to it.
Usage
var sync = true,
fileWriter = new require('istanbul').FileWriter(sync);
fileWriter.on('done', function () { console.log('done'); });
fileWriter.copyFile('/foo/bar.jpg', '/baz/bar.jpg');
fileWriter.writeFile('/foo/index.html', function (contentWriter) {
contentWriter.println('<html>');
contentWriter.println('</html>');
});
fileWriter.done(); // will emit the done event when all files are written
Constructor
FileWriter
(
-
sync
Parameters:
-
syncObject
Methods
copyFile
(
-
source -
dest
copies a file from source to destination
Parameters:
-
sourceStringthe file to copy, found on the file system
-
destStringthe destination path
done
()
marker method to indicate that the caller is done with this writer object
The writer is expected to emit a done event only after this method is called
and it is truly done.
writeFile
(
-
file -
callback
allows writing content to a file using a callback that is passed a content writer
Parameters:
-
fileStringthe name of the file to write
-
callbackFunctionthe callback that is called as
callback(contentWriter)
