transpile-watch
Utility script for transpiling files (es6, scss, ...) and to watch for changes. Convenience wrapper around chokidar.
Invocation
const watcher = ; watcher;
watch()
returns the Chokidar watcher object:
const chokidarWatcher = ;chokidarWatcher;
Options
what
String: directory to watch
ignore
String: directory to ignore
persistent
Boolean: set to true
to keep watching
extension
String: include filter for files to process
createOutPath
Function: function(inPath) -> String
: function to transform a path to an out path, for instance es6
to js
transform
Function: function(inPath, outPath) -> String
: function to do the transpiling
transformed
Function: function()
: called after the transform function has been completed
validPath
Function: function(inPath) -> Boolean
: function to check the validity of the path
debug
Boolean: set to true
to log the results of the transform function
events
Array: ['eventName', 'eventName']
: Transpile on defined events. Available events are: ready, add, change, unlink, addDir, unlinkDir (related to chokidar's events). If the event ready is choosen, transpiling does not start directly running the script.
Example
Example script to transpile es6 files:
'use strict'; // argv[2]: state (run once or watch)// argv[3]: which dir to watch// argv[4]: which dir to ignore const watch = ;;
Invoked to run once:
"transpile-es6": "node scripts/watcher.js once src/"
Invoked to watch:
"watch-es6": "node scripts/watcher.js watch src/"