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:
-
sync
Object
Methods
copyFile
(
-
source
-
dest
copies a file from source to destination
Parameters:
-
source
Stringthe file to copy, found on the file system
-
dest
Stringthe 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:
-
file
Stringthe name of the file to write
-
callback
Functionthe callback that is called as
callback(contentWriter)