Task Automation

Mohammad Umair Khan

mohammadumairkh

mohammadumairkhan

Doing same tasks is boring

and also prone to errors !

Thats what usually interns are hired for ...

 

There are exactly 2 ways to address this ...

Keep doing it for the rest of your life

Act smart and do some automation

Sales pitch !

  • Improved quality of deliverables
  • Automation of monotonus yet critical workflows
  • Faster and consistent than manual processes
  • Automate tasks you don't want to do e.g. minification, running unit tests, scaffolding a release

 

 

So we work smarter rather than working harder!

What are Grunt and Gulp?

 

 

 

 

 

Task automation tools that run on Node.js

 

 

Cross platform runtime environment based on Google Chrome V8 Javascript Engine

Node Packaged Modules is the official package manager for Node JS

What JS?

How are they different?

Configuration over code

File based I/O

Code over configuration

Stream based I/O

Grunt Task

Workflow

Installation

Grunt declared as dev-dependency on the 'NPM' package.json file

Gruntfile placed usually on the root of the project

Installing plugins

There are grunt plugins available for the tasks you want to perform

Configuring Gruntfile and plugins

Configuring custom tasks

Execute Grunt Tasks

DEMO

Gulp Task

Workflow

Installation

Global Install

Local Install

Install Plugins

There are gulp plugins available for the tasks you want to perform

Code your tasks

4 simple APIs

Gulp.task

gulp.task(name[, deps], fn)

Declare a task, optionally declare dependencies

Gulp.src

gulp.src(globs[, options])

Takes in a set of files (glob) and returns it

Gulp.dest

gulp.dest(path)

Takes in a folder path to output the result

Gulp.watch

gulp.watch(glob [, opts], tasks)

Executes the tasks when the glob changes

.pipe() ?

readable.pipe(destination, [opts])

This method pulls all the data out of a readable stream, and writes it to the supplied destination

API from Node Streams

Chaining

Tasks run in parallel, so we need to declare explicit dependencies to chain them

DEMO

Power of Automation

?

or

Grunt 

  • File based
  • 2400+ plugins
  • 2+ years old
  • Widely used

Gulp

  • Stream based
  • 400+ plugins
  • 1+ years old
  • Catching on ...

http://www.yeoman.io

Where do i go?

http://www.gulpjs.com

http://www.gruntjs.com

Source

Credits

@john_papa

@eibrahim

Task Automation

By Mohammad Umair Khan

Task Automation

Workflow automation not only speeds up the development process but also adds credibility to development and release cycles. This is a short technical presentation to demonstrate the use of Node packages like Grunt and Gulp for Task/Workflow automation.

  • 1,346