mission

2019-09-13

Common used tasks in Web development

Mission: common tasks in Web development

Bundled tasks for developing single page apps.

Usage

npm install --save-dev mission shelljs

Config in CoffeeScript or JavaScript:

#!/usr/bin/env coffee
require 'shelljs/make'

mission = require 'mission'

target.coffee = ->
  mission.coffee
    from: 'src/'
    files: ['a.coffee', 'dir/b.coffee']
    to: 'lib/'
    options:
      bare: yes

Here's mine: https://github.com/jiyinyiyong/mk/blob/master/make.coffee

Run it like this:

chmod +x make.coffee
./make.coffee coffee

or like me:

alias mk='coffee make.coffee'
mk coffee

Other configurations

Say if you want to compile only one file:

target.coffee = ->
  mission.coffee
    file: 'a.coffee'
    from: 'src/'
    to: 'lib/'
    options:
      bare: yes

Or you may need to find some files that are deep in folders:

target.coffee = ->
  mission.coffee
    find: /\.coffee$/
    from: 'src/'
    to: 'lib/'
    options:
      bare: yes

fromand toare optional, you mat only need to write filesometimes:

target.coffee = ->
  mission.watch
    file: 'dir'
    trigger: (filename, extname) ->

Usage

  • tree: creates file tree

  • bump: bump version with semver.

  • uglify: minify JavaScript code

  • coffee: compile CoffeeScript to JavaScript, with sourceMap support

  • watch: watch directories, callback filenames and extnames

  • time: log the time it cost

  • realod: reload tab with devtools-reloader-station

  • browserify: combine JavaScript code on CommonJS

  • browserifyVender: helper for browserifyto generate vender.js

  • cssmin: combine CSS files and minify code

  • dot: precompile dot files to JavaScript

  • jade: compile Jade to HTML

  • less: compile LESS to CSS

SourceMap is enabled by default, and here I have to use command line. Related to: https://github.com/less/less.js/issues/1985Anyway, mission.lessneeds to be updated in the future.

  • rsync: run Rsync with some default configs

  • copy: copy files and directories

  • wait: wait chan.done = falseto be trueand run task

  • cirruHtmlcompile Cirru HTML

  • cirruHtmlJscompile Cirru to template in JavaScript(not tested)

Notice

Asynchronous callings are hard to handle in ShellJS. In this angle, Grunt did a good job in sequencing tasks.

But you can try waitto reduce the pain. missionwould keep watching .doneand run task when it's true.

target.test = ->
  a = done: no
  mission.wait a, ->
    console.log 'finish task'

  setTimeout ->
    a.done = yes
  , 2000

Development

Compile *.coffee:

./make.coffee compile

Changelog

  • 0.0.8

    • add externaloption for browserify

    • add browserifyVendertask for multiple bundling

  • 0.0.7

    • Add cirruHtmlJsand rename cirruHtml
  • 0.0.6

    • Updated Cirru HTML to fix double quote in attributes
  • 0.0.5

    • Added sourceMapsupport
  • 0.0.4

    • Added flexibility and some default options to rsync

License

MIT

HomePage

https://github.com/jiyinyiyong/mission

Repository

https://github.com/jiyinyiyong/mission.git


上一篇:cirru-html
下一篇:aeterno
相关教程
关注微信

扫码加入 JavaScript 社区

相关文章

首次访问,需要验证
微信扫码,关注即可
(仅需验证一次)

欢迎加入 JavaScript 社区

号内回复关键字:

回到顶部