Skip to content
Permalink
Browse files

fix(watching tests): add extname to file in watch.getFileInfo()

  • Loading branch information
jyounce committed Mar 23, 2018
1 parent 31f84da commit c7fdaa512111ca133edde1ba7fc24a078f333a30
Showing with 15 additions and 12 deletions.
  1. +5 −0 src/helpers/watch.coffee
  2. +10 −12 src/tasks/watch/watch.coffee
@@ -42,11 +42,16 @@ module.exports = (config) ->

getFileInfo: (_event, _path, globs) ->
_path = pathHelp.format _path
filename = path.basename _path
extname = path.extname filename
cwd = pathHelp.format process.cwd()
base = @_getBasepath _path, globs
relative = path.relative base, _path
relative = pathHelp.format relative
file = {
event: _event
extname
filename
cwd
base
path: _path
@@ -6,6 +6,7 @@ module.exports = (config, gulp, Task) ->
# ========
q = require 'q'
path = require 'path'
pathHelp = require "#{config.req.helpers}/path"
log = require "#{config.req.helpers}/log"
watchHelper = require("#{config.req.helpers}/watch") config
watchStore = require("#{config.req.manage}/watch-store") config
@@ -29,40 +30,37 @@ module.exports = (config, gulp, Task) ->
'app'

getClientOrServer = (file) ->
return 'client' if file.path
.indexOf(config.src[file.rbAppOrRb].server.scripts.dir) is -1
serverDir = pathHelp.format config.src[file.rbAppOrRb].server.scripts.dir
return 'client' if file.path.indexOf(serverDir) is -1
'server'

getRelative = (file) ->
dir = path.dirname file.relative
return '' if dir is '.'
dir

getFileName = (file) ->
fileName = path.basename file.path
fileName

getDistDir = (file, opts={}) ->
dir = config.dist[file.rbAppOrRb][file.rbClientOrServer][opts.srcType].dir
dir = path.join dir, file.rbRelative
dir = pathHelp.format dir
dir

getDistPath = (file, opts={}) ->
fileName = file.rbFileName
if opts.extDist
extSrc = path.extname fileName
fileName = fileName.replace extSrc, ".#{opts.extDist}"
dPath = path.join file.rbDistDir, fileName
filename = file.filename
if opts.extDist # swap src ext with dist ext
filename = filename.replace file.extname, ".#{opts.extDist}"
dPath = path.join file.rbDistDir, filename
dPath = pathHelp.format dPath
dPath

addFileProps = (file, opts={}) -> # must be in order
file.rbAppOrRb = getAppOrRb file
file.rbClientOrServer = getClientOrServer file
file.rbRelative = getRelative file
file.rbFileName = getFileName file
file.rbDistDir = getDistDir file, opts
file.rbDistPath = getDistPath file, opts
file.rbLog = opts.logWatch if opts.addLog
# log.json file, 'WATCH FILE:'
file

# event tasks

0 comments on commit c7fdaa5

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