-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathCakefile
36 lines (32 loc) · 1.45 KB
/
Cakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
fs = require 'fs'
path = require 'path'
{ run, compileScript, readFile, writeFile, exec, notify } = require 'muffin'
# In Node.js 0.8.x, existsSync moved from path to fs.
existsSync = fs.existsSync or path.existsSync
task 'build', 'compile coffeescript → javascript', (options) ->
run
options:options
files:[
"./src/**/*.coffee"
"package.json"
]
map:
'src/(.+).coffee': (m) ->
compileScript m[0], path.join("lib" ,"#{m[1]}.js"), options
'package.json': (m) ->
writeNameAndVersion = (name, version) ->
data = "module.exports=\"#{version}\"\n"
writeFile("lib/version.js", data).then ->
notify m[0], "Extracted version: #{version}"
data = "module.exports=\"#{name}\"\n"
writeFile("lib/name.js", data).then ->
notify m[0], "Extracted name: #{name}"
readFile(m[0]).then (item) ->
{ name, version } = JSON.parse(item)
if existsSync('.git')
exec('git describe --tags --dirty')[1].then (out) ->
# Remove leading "v" and trailing \n
version = out[0].slice(1, -1)
writeNameAndVersion name, version
else
writeNameAndVersion name, version