Skip to content
Permalink
Browse files

feat(options): change option spa.exclude value to be an array of strings

  • Loading branch information
jyounce committed Jun 17, 2015
1 parent 99564c2 commit 171426ff1c3e1f6fbae71666d1cf260e19b6f531
Showing with 18 additions and 28 deletions.
  1. +2 −3 README.md
  2. +3 −12 config/config-options.coffee
  3. +1 −6 config/config-spa.coffee
  4. +12 −7 tasks/build/build-spa.coffee
@@ -87,9 +87,8 @@ gulp rapid-build:prod
# spa.src.file = (string) defaults to 'spa.html' = set if you want to use your own spa file and not the build system's (file must be located in your client src directory)
# spa.src.dir = (string) defaults to null = set if you are using your own spa file and that file is located in a directory in your client src directory
# spa.dist.file = (string) defaults to spa.src.file or 'spa.html' = provide if you want the dist spa file to be named differently, example: 'index.html'
# spa.exclude.styles = (boolean) defaults to false = set to true to exclude styles from the spa file
# spa.exclude.scripts = (boolean) defaults to false = set to true to exclude scripts from the spa file
# ==============================================================================================================================================================================================================
# spa.exclude = (array of strings) = set to retain spa file placeholders, optional values are: ['scripts', 'styles', 'description', 'moduleName', 'title'] or ['all']
# ==========================================================================================================================================================================================================
```

## Build Modes
@@ -26,12 +26,8 @@
# spa.src.file = (string) defaults to 'spa.html'
# spa.src.dir = (string) defaults to null
# spa.dist.file = (string) defaults to spa.src.file or 'spa.html'
# spa.exclude.styles = (boolean) defaults to false
# spa.exclude.scripts = (boolean) defaults to false
# spa.exclude.title = (boolean) defaults to false
# spa.exclude.moduleName = (boolean) defaults to false
# spa.exclude.description = (boolean) defaults to false
# ===============================================================================================================================
# spa.exclude = (array of strings) = optionals: ['scripts', 'styles', 'description', 'moduleName', 'title'] or ['all']
# =====================================================================================================================================================
module.exports = (config, options) ->
log = require "#{config.req.helpers}/log"
isType = require "#{config.req.helpers}/isType"
@@ -87,15 +83,10 @@ module.exports = (config, options) ->
options.spa.description = null if not isType.string options.spa.description
options.spa.src = {} if not isType.object options.spa.src
options.spa.dist = {} if not isType.object options.spa.dist
options.spa.exclude = {} if not isType.object options.spa.exclude
options.spa.exclude = null if not isType.array options.spa.exclude
options.spa.src.dir = null if not isType.string options.spa.src.dir
options.spa.src.file = null if not isType.string options.spa.src.file
options.spa.dist.file = null if not isType.string options.spa.dist.file
options.spa.exclude.styles = null if not isType.boolean options.spa.exclude.styles
options.spa.exclude.scripts = null if not isType.boolean options.spa.exclude.scripts
options.spa.exclude.title = null if not isType.boolean options.spa.exclude.title
options.spa.exclude.moduleName = null if not isType.boolean options.spa.exclude.moduleName
options.spa.exclude.description = null if not isType.boolean options.spa.exclude.description

distAndSrcOptions()
serverOptions()
@@ -46,12 +46,7 @@ module.exports = (config, options) ->

# exclude
# =======
spa.exclude =
styles: options.spa.exclude.styles or false
scripts: options.spa.exclude.scripts or false
title: options.spa.exclude.title or false
moduleName: options.spa.exclude.moduleName or false
description: options.spa.exclude.description or false
spa.exclude = options.spa.exclude or []

# add spa to config
# =================
@@ -11,22 +11,27 @@ module.exports = (gulp, config) ->
# helpers
# =======
runReplace = (type) ->
newKey = "<%= #{type} %>"
key = "<!--#include #{type}-->"
exclude = config.spa.exclude[type]
gulpif not exclude, replace key, newKey
newKey = "<%= #{type} %>"
key = "<!--#include #{type}-->"
exclude = config.spa.exclude
replacePH = true # PH = placeholder
if exclude.indexOf('all') isnt -1
replacePH = false
else if exclude.indexOf(type) isnt -1
replacePH = false
gulpif replacePH, replace key, newKey

# task
# ====
runTask = (src, dest, file, data={}) ->
defer = q.defer()
gulp.src src
.pipe rename file
.pipe runReplace 'styles'
.pipe runReplace 'scripts'
.pipe runReplace 'description'
.pipe runReplace 'moduleName'
.pipe runReplace 'scripts'
.pipe runReplace 'styles'
.pipe runReplace 'title'
.pipe runReplace 'description'
.pipe template data
.pipe gulp.dest dest
.on 'end', ->

0 comments on commit 171426f

Please sign in to comment.
You can’t perform that action at this time.