A Bystander plugin for writing to JavaScript files.
A Bystander plugin to auto-write compiled code to JavaScript files.
Note, for now, it has to be used in conjunction with by-coffeescript plugin, and it only works with CoffeeScript-to-Javascript compiled code.
To install by-write2js,
sudo npm install -g by-write2js
bin: true to map a.bin.coffeefile to a no extension file. (e.g.write2js.bin.coffeetowrite2.js)binDir: a directory to save no extension bin files.mapper: an array of key-value pairs to map CoffeeScript source files to output Javascript files. The key is a glob pattern, and the value is an array of arguments to pass toreplace()method or afunctionthat returns a bloolean value.
By-Write2JS uses minimatch without matchBase option to match glob patterns.
Saving compiled files from src directory into lib directory, and .bin.coffee files into bin directory.
// .bystander config file
.....
.....
"plugins" : ["by-coffeescript", "by-write2js"],
"by" : {
"write2js" : {
"mapper" : ["**/src/*", [/src/i, "/lib/"]],
"bin" : true,
"binDir" : "./bin"
}
},
.....
.....Note, .coffee will be automatically replaced with .js, and binDir will be resolved against the project root path, not the current working directory.
wrote2js: successfully wrote to the corresponding js file after a coffeecompiledeventwrite2js error: failed to write to the js fileunlink error: failed to remove the given js filejs removed: removed the correspoding js file after a coffeeFile removedevent
See the annotated source for details.
Run tests with mocha
makeBy-Write2js is released under the MIT License. - see the LICENSE file