mikedmcfarland / engulped

Utilities for defining common gulp tasks centered around transpiling and testing es6 (via babel and mocha)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Engulped

Engulped provides utilities for defining some common build build tasks for es6 using babel and mocha. I kept needing the same tasks in many of my projects, so this tool makes it possible to add each in as needed.

How do I use this?

The most common usage is to add all the default tasks. To do so, your gulpfile would look like the following

var gulp     = require('gulp')
var Engulped = require('engulped')

var engulped = Engulped.withDefaultTasks(gulp)
gulp.task('default',['test','build'])

This automatically adds many tasks to gulp. The default task added uses the added tasks oo run all specs with mocha and transpiles to es6 to es5.

You can then optionally overwrite them as needed

gulp.task('clean',function(){
  console.log('feeling clean')
})

You can also reference the original function used to generate the tasks via the -tasks- method. For example, here’s how you’d overwrite clean with the same implementation:

var tasks = engulped.tasks()
gulp.task('clean',tasks.clean())

Some taskbuilding functions have parameters they accept, take a look at -lib/addDefaultTasks.js- and -lib/taskBuilders- for more information.

What are the tasks?

clean

Cleans the directory of files created by transpiling

build

Transpile source files in -src- from es6 to es5 (src -> dest) (via babel)

test

Run all specs in test directory (es6 registered) (via mocha)

watch

Runs the default task on any file changes (via nodemon)

I’d rather not have all these tasks added

Then you can create it with the constructor instead, and add them manually

var gulp     = require('gulp')
var Engulped = require('engulped')

var engulped = new Engulped(gulp)
var tasks = engulped.tasks()

gulp.task('clean',tasks.clean())

I’d like to set different src and dest directories for my tasks

You can pass a configuration as the second parameter to the constructor or Engulped.withDefaultTasks. The default config looks something like:

{argv : process.argv,
 paths : {
   script : {
     src  : './lib/',
     dest : './dist/',
     pattern : '/**/*.js'
   },
   test : {
     src  : './test/',
     pattern : '/**/**Spec.js'
   }
 }

Planned

Add documention for adding custom task builders

Add documention for task builders

About

Utilities for defining common gulp tasks centered around transpiling and testing es6 (via babel and mocha)


Languages

Language:JavaScript 98.9%Language:Shell 1.1%