Skip to content
Permalink
Browse files

fix(spa watch): fix the watch on the custom spa.html

  • Loading branch information
jyounce committed Jun 6, 2016
1 parent fb8c9c3 commit 3df516a00edf07d11551b25c8b38fa038755435a
@@ -14,12 +14,14 @@ module.exports = (config) ->
generated.dir = 'generated'
generated.path = join config.rb.root, generated.dir
generated.pkg = {}
generated.pkg.dir = config.app.name
generated.pkg.path = join generated.path, generated.pkg.dir
generated.pkg.bower = join generated.pkg.path, 'bower.json'
generated.pkg.config = join generated.pkg.path, 'config.json'
generated.pkg.files = {}
generated.pkg.src = {}
generated.pkg.dir = config.app.name
generated.pkg.relPath = join generated.dir, generated.pkg.dir
generated.pkg.path = join generated.path, generated.pkg.dir
generated.pkg.bower = join generated.pkg.path, 'bower.json'
generated.pkg.config = join generated.pkg.path, 'config.json'
generated.pkg.files = {}
generated.pkg.src = {}
generated.pkg.temp = {}
generated.pkg.files.dir = 'files'
generated.pkg.files.path = join generated.pkg.path, generated.pkg.files.dir
generated.pkg.files.files = join generated.pkg.files.path, 'files.json'
@@ -31,6 +33,9 @@ module.exports = (config) ->
generated.pkg.src.server = {}
generated.pkg.src.server.path = join generated.pkg.src.path, 'server'
generated.pkg.src.server.info = join generated.pkg.src.server.path, 'server-info.json'
generated.pkg.temp.dir = 'temp'
generated.pkg.temp.relPath = join generated.pkg.relPath, generated.pkg.temp.dir
generated.pkg.temp.path = join generated.pkg.path, generated.pkg.temp.dir

# add generated to config
# =======================
@@ -26,6 +26,7 @@ module.exports = (config, options) ->
distFile = options.spa.dist.fileName or srcFile
distFilePath = path.join config.dist.app.client.dir, distFile
distFileAbsPath = path.join config.app.dir, distFilePath
tempFilePath = path.join config.generated.pkg.temp.path, distFilePath

# init spa
# ========
@@ -55,6 +56,11 @@ module.exports = (config, options) ->
dir: srcDir
path: srcFilePath

# temp
# ====
spa.temp =
path: tempFilePath

# placeholders
# ============
spa.placeholders = options.spa.placeholders or []
@@ -79,7 +79,7 @@ module.exports = (config, gulp, taskOpts={}) ->
data = getData json
tasks = [
-> buildTask(
config.spa.dist.absPath
config.spa.temp.path
config.dist.app.client.dir
config.spa.dist.file
data
@@ -174,7 +174,7 @@ module.exports = (config, gulp) ->

# return
# ======
api.runTask config.spa.dist.absPath
api.runTask config.spa.temp.path



@@ -1,20 +1,17 @@
module.exports = (config, gulp) ->
q = require 'q'
rename = require 'gulp-rename'
q = require 'q'
fse = require 'fs-extra'

# API
# ===
api =
runTask: ->
defer = q.defer()
src = config.spa.src.path
dest = config.dist.app.client.dir
file = config.spa.dist.file
gulp.src src
.pipe rename file # if options.spa.dist.fileName
.pipe gulp.dest dest
.on 'end', ->
defer.resolve()
dest = config.spa.temp.path
opts = clobber: true
fse.copy src, dest, opts, (e) ->
defer.resolve()
defer.promise

# return
@@ -25,6 +25,14 @@ module.exports = (config) ->
defer.resolve()
defer.promise

createDir = (dir) ->
defer = q.defer()
_path = config.generated.pkg[dir].path
fse.mkdirs _path, (e) ->
# console.log "generated #{dir} directory".yellow
defer.resolve()
defer.promise

# private
# =======
_api =
@@ -41,21 +49,22 @@ module.exports = (config) ->
pkg: ->
root = path.join config.generated.pkg.path, '*.*'
files = config.generated.pkg.files.path
temp = config.generated.pkg.temp.path
server = path.join config.src.rb.server.dir
client = path.join config.src.rb.client.dir, '*'
bower = "!#{config.src.rb.client.bower.dir}"
paths = [root, files, server, client, bower]
paths = [root, files, temp, server, client, bower]
delDir paths, config.generated.pkg.dir

create:
dirs: ->
defer = q.defer()
_path = config.generated.pkg.files.path
fse.mkdirs _path, (e) ->
q.all([
createDir 'files'
createDir 'temp'
])
.done ->
dir = config.generated.pkg.dir
console.log "generated #{dir} directory".yellow
defer.resolve()
defer.promise

jsonFiles: ->
pkg = config.generated.pkg

0 comments on commit 3df516a

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