Skip to content

Commit

Permalink
switch to mission
Browse files Browse the repository at this point in the history
  • Loading branch information
tiye committed May 8, 2014
1 parent 1e246a6 commit 276b5c4
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 69 deletions.
1 change: 1 addition & 0 deletions .npmignore
Expand Up @@ -8,3 +8,4 @@
/index.html
/*.coffee
/js/live.js
/html/
10 changes: 0 additions & 10 deletions index.html

This file was deleted.

113 changes: 56 additions & 57 deletions make.coffee
@@ -1,70 +1,69 @@
#!/usr/bin/env coffee

project = 'repo/cirru/parser'
interval = interval: 300
watch = no

require 'shelljs/make'
fs = require 'fs'
station = require 'devtools-reloader-station'
browserify = require 'browserify'
exorcist = require 'exorcist'
{renderer} = require 'cirru-html'

startTime = (new Date).getTime()
process.on 'exit', ->
now = (new Date).getTime()
duration = (now - startTime) / 1000
console.log "\nfinished in #{duration}s"

reload = -> station.reload project if watch

compileCoffee = (name, callback) ->
exec "coffee -o js/ -bc coffee/#{name}", ->
console.log "done: coffee, compiled coffee/#{name}"
do callback

packJS = ->
bundle = browserify ['./js/main']
.bundle debug: yes
bundle.pipe (exorcist 'build/build.js.map')
.pipe (fs.createWriteStream 'build/build.js', 'utf8')
bundle.on 'end', ->
console.log 'done: browserify'
do reload
path = require 'path'

mission = require 'mission'
mission.time()

target.folder = ->
mkdir '-p', 'cirru', 'coffee', 'js', 'build', 'css'
exec 'touch cirru/index.cirru css/style.css'
exec 'touch coffee/main.coffee'
exec 'touch README.md .gitignore .npmignore'

target.html = ->
file = 'cirru/index.cirru'
render = renderer (cat file), '@filename': file
html = render()
fs.writeFile 'index.html', html, 'utf8', (err) ->
console.log 'done: cirru'
do reload

target.js = ->
exec 'coffee -o js/ -bc coffee/'
mission.tree
'.gitignore': ''
'README.md': ''
js: {}
build: {}
cirru: {'index.cirru': ''}
coffee: {'main.coffee': ''}
css: {'style.css': ''}

target.coffee = ->
mission.coffee
find: /\.coffee$/, from: 'coffee/', to: 'js/', extname: '.js'
options:
bare: yes

cirru = ->
mission.cirru
file: 'index.cirru', from: 'cirru/', to: './', extname: '.html'

browserify = (callback) ->
mission.browserify
file: 'main.js', from: 'js/', to: 'build/', done: callback

target.cirru = -> cirru()
target.browserify = -> browserify()

target.compile = ->
target.html()
exec 'coffee -o js/ -bc coffee/', ->
packJS()
cirru()
target.coffee yes
browserify()

target.watch = ->
watch = yes
fs.watch 'cirru/', interval, ->
target.html()
fs.watch 'coffee/', interval, (type, name) ->
if type is 'change'
compileCoffee name, ->
do packJS

station.start()
station = mission.reload()

mission.watch
files: ['cirru/', 'coffee/']
trigger: (filepath, extname) ->
switch extname
when '.cirru'
cirru()
station.reload project
when '.coffee'
filepath = path.relative 'coffee/', filepath
mission.coffee
file: filepath, from: 'coffee/', to: 'js/', extname: '.js'
options:
bare: yes
browserify ->
station.reload project

target.pre = ->
target.compile()
mission.bump
file: 'package.json'
options:
at: 'prerelease'

names = [
'demo'
Expand Down
5 changes: 3 additions & 2 deletions package.json
Expand Up @@ -4,7 +4,7 @@
"description": "Parser for Cirru Grammer",
"main": "js/parser.js",
"scripts": {
"test": "coffee test.coffee"
"test": "./make.coffee test"
},
"repository": {
"type": "git",
Expand All @@ -17,7 +17,8 @@
"author": "jiyinyiyong",
"license": "MIT",
"devDependencies": {
"exorcist": "^0.1.6"
"mission": "0.0.1-3",
"shelljs": "^0.2.6"
},
"dependencies": {},
"bugs": {
Expand Down

0 comments on commit 276b5c4

Please sign in to comment.