forked from shprink/BttrLazyLoading
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cakefile
64 lines (51 loc) · 1.65 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
fs = require 'fs'
{exec} = require 'child_process'
flour = require 'flour'
FILE_COFFEE = 'BttrLazyLoading.coffee'
FILE_CSS = 'bttrlazyloading.css'
FILE_MINIFIED_JS = 'jquery.bttrlazyloading.min.js'
FILE_MINIFIED_CSS = 'bttrlazyloading.min.css'
FILE_VERSION = 'version'
task 'build', 'Compile and minify', ->
invoke 'build:coffee'
invoke 'build:css'
task 'build:coffee', 'Build CoffeeScript', ->
bundle FILE_COFFEE, FILE_MINIFIED_JS, ->
prependCopyright FILE_MINIFIED_JS
task 'build:css', 'Build CSS', ->
minify FILE_CSS, FILE_MINIFIED_CSS, ->
prependCopyright FILE_MINIFIED_CSS
task 'dev', 'Lints, builds and keeps watching for changes', ->
invoke 'build'
invoke 'watch'
task 'lint', 'Run linting for CoffeeScript and JavaScript', ->
lint ['./test/spec.js', FILE_COFFEE, 'Cakefile']
task 'watch', 'Watch for changes', ->
watch 'bttrlazyloading.css', ->
invoke 'build:css'
watch 'BttrLazyLoading.coffee', ->
invoke 'lint'
invoke 'build:coffee'
watch ['Cakefile', './test/spec.js', FILE_COFFEE], ->
invoke 'lint'
invoke 'build'
prependCopyright = (file) ->
try
minifiedJs = fs.readFileSync(file, { "encoding" : "utf8" })
fs.writeFile file, copyright + minifiedJs, () ->
console.log "Copyright added successfully"
catch e
console.warn "Failed to prepend copyright"
# Get the current version
getVersion = ->
"#{fs.readFileSync FILE_VERSION}"
copyright =
"""
/*
BttrLazyLoading, Responsive Lazy Loading plugin for JQuery
by Julien Renaux http://bttrlazyloading.julienrenaux.fr
Version #{getVersion()}
Full source at https://github.com/shprink/BttrLazyLoading
MIT License, https://github.com/shprink/BttrLazyLoading/blob/master/LICENSE
*/
"""