Skip to content

Commit

Permalink
Merge pull request #56 from krmorse/master
Browse files Browse the repository at this point in the history
Fix watch from crashing when there are app build errors
  • Loading branch information
krmorse committed Apr 28, 2016
2 parents 9435c1d + a6d2ea3 commit ca8955a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
14 changes: 10 additions & 4 deletions lib/build/get-script.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports =
getFiles: ({configJson, appPath}, callback)->
localFiles = _.filter(configJson.javascript, isScriptLocal)
localCssFiles = _.filter(configJson.css, isScriptLocal)
async.parallel
async.series
javascript_files: (jsCallback)=>
@getJavaScripts {appPath, scripts: localFiles, compress:true}, jsCallback
uncompressed_javascript_files: (jsCallback)=>
Expand Down Expand Up @@ -46,7 +46,14 @@ module.exports =
for key,code of results
fileName = scripts[key]
@hintJavaScriptFile(code, fileName)
results[key] = if compress then @compressJavaScript(code) else code
if compress
try
results[key] = @compressJavaScript code
catch e
callback new Error()
return
else
results[key] = code
callback(null, results)

getStylesheets: ({appPath, scripts, compress}, callback)->
Expand All @@ -66,9 +73,8 @@ module.exports =
compressJavaScript: (code)->
ast = uglify.parse(code)
ast.figure_out_scope()
compressor = uglify.Compressor(
compressor = uglify.Compressor
unused: false
)
ast = ast.transform(compressor)
return ast.print_to_string()

Expand Down
6 changes: 4 additions & 2 deletions lib/watch.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ build = require './build'
watcher = null

onChange = (args) ->
console.log "\nRebuilding...\n"
console.log('Rebuilding...\n');
path = process.cwd()
{templates} = args
watcher.close()
Expand All @@ -13,6 +13,8 @@ watch = (args) ->
{templates} = args
console.log('\nWatching for changes...')
watcher = chokidar.watch process.cwd(), { usePolling: true, interval: 500 }
watcher.on 'change', () -> onChange {templates}
watcher.on 'change', (path) ->
console.log('\nChange detected:', path);
onChange {templates}

module.exports = watch
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"author": "Kyle Morse <[email protected]>",
"name": "rally-app-builder",
"description": "A node module that assists in the building of Rally Apps",
"version": "1.2.6",
"version": "1.2.7",
"homepage": "https://github.com/rallyapps/rally-app-builder",
"repository": {
"type": "git",
Expand Down

0 comments on commit ca8955a

Please sign in to comment.