Skip to content

Commit

Permalink
Add more possible overwrites, defaults, and renaming capability
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Litwin committed Dec 1, 2015
1 parent 48de52a commit 3bd76ba
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"gulp-plumber": "^1.0.0",
"gulp-protractor": "^1.0.0",
"gulp-remove-code": "^1.0.2",
"gulp-rename": "^1.2.2",
"gulp-rev": "^5.0.1",
"gulp-rev-replace": "^0.4.2",
"gulp-sass": "^1.3.3",
Expand Down
19 changes: 12 additions & 7 deletions tasks/ng-constant.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,28 @@ defaultNgConstants =
AUTH0_TOKEN_NAME : 'userJWTToken'
AUTH0_REFRESH_TOKEN_NAME: 'userRefreshJWTToken'

defaultDestPath = '.tmp/scripts'
defaultDestPath = '.tmp/scripts'
defaultFileName = 'constants.js'
defaultModuleName = 'app.constants'

module.exports = (gulp, $, configs) ->
destPath = configs.ngConstants?.destPath || defaultDestPath
constants = {}
destPath = configs.ngConstants?.destPath || defaultDestPath
defaultNgConstants = configs.ngConstants?.defaultConstants || defaultNgConstants
fileName = configs.ngConstants?.fileName || defaultFileName
moduleName = configs.ngConstants?.options?.name || defaultModuleName
constants = {}

for key, defaultConstant of defaultNgConstants
envVal = configs.env.getVal key
constants[key] = configs.ngConstants?.constants?[key] || envVal || defaultConstant

gulp.task 'ng-constant', ->
options =
name : 'app.constants'
name : moduleName
constants: constants
stream : true

dest = gulp.dest destPath

$.ngConstant(options).pipe dest
dest = gulp.dest destPath
rename = $.rename fileName

$.ngConstant(options).pipe(rename).pipe dest

0 comments on commit 3bd76ba

Please sign in to comment.