Skip to content

Commit

Permalink
Merge pull request #542 from realtymapsDev/dev/nem/gulpFixes
Browse files Browse the repository at this point in the history
gulp fixes and reverts
  • Loading branch information
nmccready committed Sep 14, 2015
2 parents 9997b71 + f8ac745 commit 31a6a04
Show file tree
Hide file tree
Showing 8 changed files with 127 additions and 34 deletions.
6 changes: 0 additions & 6 deletions backend/config/express.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,6 @@ app.use helmet.nocache()
# ensure all assets and data are compressed - above static
app.use compress()

# setting the favicon and static folder
# NOTE TODO: THIS IS THE ONLY DEPENDENCY THAT EXPRESS HAS on Assets to be compiled prior
# THEREFORE it would be nice to set this setting reactivley at a later time to speed up builds.
app.use favicon "#{config.FRONTEND_ASSETS_PATH}/assets/favicons/favicon.ico"
app.use serveStatic config.FRONTEND_ASSETS_PATH

# cookie parser - above session
app.use cookieParser config.SESSION.secret

Expand Down
6 changes: 4 additions & 2 deletions gulp/tasks/default.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ gulp = require 'gulp'
].forEach (dep) ->
# console.log 'requiring', dep
require dep
#help = require('gulp-help')(gulp)

gulp.task 'developNoSpec', gulp.series 'clean', 'otherAssets', gulp.parallel('express', 'watch')
#this allows `gulp help` task to work which will display all taks via CLI so yes it is used
# help = require('gulp-help')(gulp) #BROKEN IN GULP 4

gulp.task 'developNoSpec', gulp.series 'clean', gulp.parallel('angular', 'angularAdmin', 'otherAssets', 'express', 'watch')

#note specs must come after watch since browserifyWatch also builds scripts
gulp.task 'develop', gulp.series 'developNoSpec', 'spec'
Expand Down
25 changes: 21 additions & 4 deletions gulp/tasks/markup.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ plumber = require 'gulp-plumber'

$ = require('gulp-load-plugins')()

_testCb = null

markup = (app) ->
_testCb() if _testCb

gulp.src paths[app].jade
.pipe plumber()
.pipe $.consolidate 'jade',
Expand All @@ -29,16 +33,29 @@ markup = (app) ->
markupImpl = -> markup 'map'
markupAdminImpl = -> markup 'admin'

watchImpl = ->
gulp.watch paths.map.jade, markupImpl

watchAdminImpl = ->
gulp.watch paths.admin.jade, markupAdminImpl

gulp.task 'markup', markupImpl

gulp.task 'markupWatch', (done) ->
gulp.watch paths.map.jade
markupImpl()
watchImpl()
done()

gulp.task 'markupAdmin', markupAdminImpl

gulp.task 'markupWatchAdmin', (done) ->
gulp.watch paths.admin.jade
markupAdminImpl()
watchAdminImpl()
done()

module.exports =
###
For intent and purposes these exports are for testing only
###
watchImpl: watchImpl
watchAdminImpl:watchAdminImpl
setTestCb: (cb) ->
_testCb = cb
6 changes: 4 additions & 2 deletions gulp/tasks/spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ require './otherAssets'
require './karma'
require './mocha'

gulp.task 'spec', gulp.parallel 'commonSpec', 'backendSpec', 'gulpSpec', 'frontendSpec'
gulp.task 'spec', gulp.series gulp.parallel('commonSpec', 'backendSpec', 'frontendSpec'), 'gulpSpec'

gulp.task 'rebuildSpec', gulp.series gulp.parallel('commonSpec', 'backendSpec', 'gulpSpec'), gulp.parallel('otherAssets', 'angular', 'angularAdmin'), 'frontendSpec'
gulp.task 'rebuildSpec', gulp.series(
gulp.parallel('commonSpec', 'backendSpec'), 'gulpSpec'
, gulp.parallel('otherAssets', 'angular', 'angularAdmin'), 'frontendSpec')

gulp.task 'rspec', gulp.series 'rebuildSpec'

Expand Down
40 changes: 29 additions & 11 deletions gulp/tasks/styles.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ gulp = require 'gulp'
conf = require './conf'
$ = require('gulp-load-plugins')()

_testCb = null

styles = (src) ->
_testCb() if _testCb

gulp.src [
src.less
src.styles
Expand Down Expand Up @@ -40,27 +44,41 @@ stylesImpl = ->
stylesAdminImpl = ->
styles paths.admin

gulp.task 'styles', stylesImpl

gulp.task 'stylesWatch', (done) ->
watchImpl = ->
gulp.watch [
paths.map.less
paths.map.styles
paths.map.stylus
]
stylesImpl()
done()

gulp.task 'stylesAdmin', stylesAdminImpl
], stylesImpl

gulp.task 'stylesWatchAdmin', (done) ->
watchAdminImpl = ->
gulp.watch [
paths.map.less
paths.map.styles
paths.map.stylus
paths.admin.less
paths.admin.styles
paths.admin.stylus
]
stylesAdminImpl()
], stylesAdminImpl

gulp.task 'styles', stylesImpl

gulp.task 'stylesWatch', (done) ->
watchImpl()
done()

gulp.task 'stylesAdmin', stylesAdminImpl

gulp.task 'stylesWatchAdmin', (done) ->
watchAdminImpl()
done()


module.exports =
###
For intent and purposes these exports are for testing only
###
watchImpl: watchImpl
watchAdminImpl:watchAdminImpl
setTestCb: (cb) ->
_testCb = cb
10 changes: 1 addition & 9 deletions gulp/tasks/watch.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,5 @@ gulp.task 'watch_all_front', gulp.parallel 'angularWatch', 'angularWatchAdmin'
gulp.task 'watch', gulp.series 'watch_all_front', (done) ->
gulp.watch ['gulp/**/*.coffee','spec/gulp/**/*.coffee', specCommon], gulp.series 'gulpSpec'
gulp.watch ['backend/**/*.coffee', 'spec/backend/**/*.coffee', specCommon], gulp.series 'backendSpec'
gulp.watch [
paths.destFull.scripts + '/map.bundle.js',
paths.destFull.scripts + '/map.templates.js',
paths.destFull.scripts + '/admin.bundle.js',
paths.destFull.scripts + '/admin.templates.js',
'spec/app/**/*.coffee',
'spec/admin/**/*.coffee',
specCommon
], gulp.series 'frontendSpec'
gulp.watch ['spec/app/**/*.coffee','spec/admin/**/*.coffee', specCommon], gulp.series 'frontendSpec'
done()
34 changes: 34 additions & 0 deletions spec/gulp/markup.spec.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
subject = require '../../gulp/tasks/markup'
_testCb = null

describe 'gulp markup', ->
beforeEach ->
_testCb = null
subject.setTestCb null

afterEach ->
_testCb = null
subject.setTestCb null

describe 'watch', ->

['map', 'admin'].map (name) ->
testName:name
camelCaseName: if name is 'map' then '' else name.toInitCaps()
. forEach (names) ->

describe names.testName, ->
it 'SHOULD ONLY WATCH', (done) ->
called = false

_testCb = ->
called = true

subject.setTestCb(_testCb)
watcher = subject["watch#{names.camelCaseName}Impl"]()

setTimeout ->
called.should.equal(false)
watcher.end()
done()
, 200
34 changes: 34 additions & 0 deletions spec/gulp/styles.spec.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
subject = require '../../gulp/tasks/styles'
_testCb = null

describe 'gulp styles', ->
beforeEach ->
_testCb = null
subject.setTestCb null

afterEach ->
_testCb = null
subject.setTestCb null

describe 'watch', ->

['map', 'admin'].map (name) ->
testName:name
camelCaseName: if name is 'map' then '' else name.toInitCaps()
. forEach (names) ->

describe names.testName, ->
it 'SHOULD ONLY WATCH', (done) ->
called = false

stylesTestCb = ->
called = true

subject.setTestCb(_testCb)
watcher = subject["watch#{names.camelCaseName}Impl"]()

setTimeout ->
called.should.equal(false)
watcher.end()
done()
, 200

0 comments on commit 31a6a04

Please sign in to comment.