Skip to content

Commit

Permalink
Added watch task and documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
thelinmichael committed Jan 27, 2014
1 parent 72a83e6 commit 447e0c3
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
24 changes: 22 additions & 2 deletions Cakefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,33 @@ task 'tag.patch', 'Patch tag incrementation', ->
tag getIncreasedVersion 'patch'

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

task 'lint', 'Run linting for CoffeeScripts', ->
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'

tag = (version) ->
# Preparing
console.log "Increasing from #{getVersion()} to #{version}..."
Expand All @@ -38,7 +58,7 @@ prependCopyright = (file) ->
try
minifiedJs = fs.readFileSync(file, { "encoding" : "utf8" })
fs.writeFile file, copyright + minifiedJs, () ->
console.log "Prepended copyright"
console.log "Copyright added successfully"
catch e
console.warn "Failed to prepend copyright"

Expand Down
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ $("#yourImageId").bttrlazyloading({
#### Prerequisites
+ [Node JS](http://julienrenaux.fr/2013/05/16/how-to-install-node-js-coffeescript-less-and-uglify-js-on-ubuntu/)
+ [Bower](http://julienrenaux.fr/2013/09/12/bower/)
+ Coffee Script (Global installation, `$ sudo npm install -g coffee-script`, is optional but convenient in the build step)
+ CoffeeScript (Global installation, `$ sudo npm install -g coffee-script`, is optional but convenient in the build step)

#### Clone the repository
`$ git clone https://github.com/shprink/BttrLazyLoading`
Expand All @@ -155,11 +155,17 @@ $ npm install
```

### Build
Compile and uglify BttrLazyLoading.coffee
Compiles and minifies BttrLazyLoading.coffee and bttrlazyloading.css.
```
cake build
```
If Coffee Script isn't globally installed, use `node_modules/.bin/cake build`
If CoffeeScript isn't globally installed, use `node_modules/.bin/cake build`

### Develop
Builds CoffeeScript and CSS, and runs linting and build steps if any changes occur to important files. This allows you to rerun the tests immidiately after you've changed the CoffeeScript, without having to lint and recompile. Of course, any changes that breaks the CoffeeScript will be prompted on the command line.
```
cake dev
```

### Run tests
Open test/index.html
Expand Down
2 changes: 1 addition & 1 deletion test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<script type="text/javascript" src="../bower_components/jasmine/lib/jasmine-core/jasmine-html.js"></script>
<script src="../bower_components/jasmine/lib/jasmine-core/boot.js"></script>
<script src="../bower_components/jquery/jquery.min.js"></script>
<script src="../jquery.bttrlazyloading.js"></script>
<script src="../jquery.bttrlazyloading.min.js"></script>
</head>
<body>
<script src="spec.js"></script>
Expand Down

0 comments on commit 447e0c3

Please sign in to comment.