Skip to content

Commit

Permalink
fix(watching tests): add extname to file in watch.getFileInfo()
Browse files Browse the repository at this point in the history
  • Loading branch information
jyounce committed Mar 23, 2018
1 parent 31f84da commit c7fdaa5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
5 changes: 5 additions & 0 deletions src/helpers/watch.coffee
Expand Up @@ -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
Expand Down
22 changes: 10 additions & 12 deletions src/tasks/watch/watch.coffee
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit c7fdaa5

Please sign in to comment.