File writer for aster.
This module is part of aster and is available via aster.dest
.
You use it in build scripts whenever you want to generate and write out processed files into folder:
var aster = require('aster');
aster.src([
'**/*.js',
'!node_modules/**'
])
.map(plugin1(optionsForPlugin1))
.map(plugin2(optionsForPlugin2))
// ...
.map(aster.dest('dist', {sourceMap: true}))
.subscribe(aster.runner);
Type: Rx.Observable
<{path: string, contents: string}>
Type: String
Destination folder.
Type: Object
aster-generate/escodegen code generation options.
Allows customizing generator to be used. By default aster-generate is used, passing options
to create the Observable
factory function.
Allows customization of the destinator function. By default the following is used. Note that options.generate
will be the generator
Obserable factory function (see options.generator
above)
function defaultDestinator(options) {
return function (files) {
files = options.generate(files);
return files
.flatMap(function (file) {
// ...
}
.flatMap(function (file) {
return writeFile(file.path, file.contents);
})
.zip(files, function (result, file) { return file });
}
}
This customization can be useful if you want to write to a destination that is not the file system, such as a database or simply to console.log
for debugging, for testing etc.