node package manager



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 file to a no extension file. (e.g. to write2.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 to replace() method or a function that returns a bloolean value.
noWrite : an array of glob patterns for files to ignore.

By-Write2JS uses minimatch without matchBase option to match glob patterns.


Saving compiled files from src directory into lib directory, and files into bin directory while ignoring files under ignore directory.

// .bystander config file
  "plugins" : ["by-coffeescript", "by-write2js"],
  "by" : {
    "write2js" : {
      "mapper" : ["**/src/*", [/src/i, "/lib/"]],
      "bin" : true,
      "binDir" : "./bin",
      "noWrite" : ["**/test/**"]

Note, .coffee will be automatically replaced with .js, and binDir will be resolved against the project root path, not the current working directory.

Broadcasted Events for further hacks

wrote2js : successfully wrote to the corresponding js file after a coffee compiled event
write2js error : failed to write to the js file
unlink error : failed to remove the given js file
js removed : removed the correspoding js file after a coffee File removed event

See the annotated source for details.

Running Tests

Run tests with mocha



By-Write2js is released under the MIT License. - see the LICENSE file