Information
Package | gulp-gorilla |
Description | Compiles Gorillascript |
Usage
let gorilla = require 'gulp-gorilla'require! gulplet gutil = require 'gulp-util' gulp.task 'gorilla', # gulp.src './src/*.gs' .pipe gorilla({ +bare }).on('error', gutil.log) .pipe gulp.dest './public/'
Error handling
gulp-gorilla will emit an error for cases such as invalid gorillascript syntax. If uncaught, the error will crash gulp.
You will need to attach a listener (i.e. .on('error')
) for the error event emitted by gulp-gorilla:
let gorilla-stream = gorilla { +bare } // Attach listenergorilla-stream.on 'error', #(err) throw? err
In addition, you may utilize gulp-util's logging function:
let gutil = require 'gulp-util' // ... let gorilla-stream = gorilla { +bare } // Attach listenergorilla-stream.on 'error', gutil.log
Since .on(...)
returns this
, you can make you can compact it as inline code:
gulp.src './src/*.gs' .pipe gorilla({ +bare }).on('error', gutil.log) // ...
Options
// default optionslet opt = bare: false source-map: false
Source maps
gulp-gorilla can be used in tandem with gulp-sourcemaps to generate source maps for the gorilla to javascript transition. You will need to initialize gulp-sourcemaps prior to running the gulp-gorilla compiler and write the source maps after.
let sourcemaps = require('gulp-sourcemaps'); gulp.src './src/*.gs' .pipe sourcemaps.init() .pipe gorilla({ +bare }).on('error', gutil.log) .pipe sourcemaps.write() .pipe './dest/js' // will write the source maps inline in the compiled javascript files
By default, gulp-sourcemaps writes the source maps inline in the compiled javascript files. To write them to a separate file, specify a relative file path in the sourcemaps.write()
function.
let sourcemaps = ; gulpsrc './src/*.gs' pipe sourcemaps pipe pipe sourcemapswrite './maps' pipe './dest/js' // will write the source maps to ./dest/js/maps
LICENSE
(MIT License)