Skip to content

Commit

Permalink
fix(task): path handling for Windows
Browse files Browse the repository at this point in the history
Changes to handling of separators to support Windows.
  • Loading branch information
laurelnaiad committed Dec 21, 2013
1 parent 19a05f8 commit 2a24cca
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "grunt-blanket-mocha-server",
"version": "0.0.0",
"version": "0.0.1",
"description": "Easily serve mocha tests with (or without) blanket coverage. \"Goes Great\" with grunt-blanket-mocha.",
"homepage": "https://github.com/stu-salsbury/grunt-blanket-mocha-server",
"author": {
Expand Down
25 changes: 17 additions & 8 deletions tasks/blanket_mocha_server.coffee
Expand Up @@ -57,17 +57,24 @@ module.exports = (grunt) ->
if preNodeModulesMatch
obj[prop] = obj[prop].replace preNodeModulesMatch[1], ''
else
inAppPath = process.cwd() + '/node_modules/grunt-blanket-mocha-server'
inAppPath = process.cwd() + path.sep + 'node_modules' + path.sep + 'grunt-blanket-mocha-server'
if !(fs.existsSync(inAppPath))
obj[prop] = obj[prop].replace(
path.resolve(__dirname + '/..'),
''
)
else
# console.log obj[prop].red
# console.log path.resolve(__dirname + '/../..').green
# console.log path.resolve(__dirname + '\\..\\..').green
obj[prop] = obj[prop].replace(
path.resolve(__dirname + '/..'),
'/node_modules/grunt-blanket-mocha-server'
path.resolve(__dirname + '/../..'),
# path.resolve(__dirname + '/..'),
'/node_modules'
# '/node_modules/grunt-blanket-mocha-server'
)
# console.log obj[prop].yellow
obj[prop] = obj[prop].replace /[\\]/g, '/'
undefined

###*
Expand All @@ -94,6 +101,7 @@ module.exports = (grunt) ->
_.each obj[prop], (val, index) ->
obj[prop][index] = path.resolve(val)
.replace(path.resolve(process.cwd()), '')
.replace(/[\\]/g, '/')

undefined

Expand Down Expand Up @@ -153,14 +161,15 @@ module.exports = (grunt) ->
'Serve runtime-configured browser-based mocha tests with ' +
'blanket.js coverage.',
() ->
myDirName = __dirname.replace /[\\]/g, '/'

gbmsLib = __dirname + '/../lib/'
gbmsSupport = __dirname + '/support/'
gbmsLib = myDirName + '/../lib/'
gbmsSupport = myDirName + '/support/'


gbmPath = '/node_modules/grunt-blanket-mocha/support'
if fs.existsSync(__dirname + '/..' + gbmPath)
gbmSupport = __dirname + '/..' + gbmPath + '/'
if fs.existsSync(myDirName + '/..' + gbmPath)
gbmSupport = myDirName + '/..' + gbmPath + '/'
else
gbmSupport = process.cwd() + gbmPath + '/'

Expand Down Expand Up @@ -211,7 +220,7 @@ module.exports = (grunt) ->
producePhantomOptions config.blanketPhantomOptions

runnerTarget = path.resolve config.htmlFile
runnerTargetDir = runnerTarget.replace /\/[^\/]*$/, '/'
runnerTargetDir = path.dirname(runnerTarget) # runnerTarget.replace /\/[^\/]*$/, '/'
if !fs.existsSync(runnerTargetDir)
grunt.log.writeln 'making runner directory: ' + runnerTargetDir
fs.mkdirSync runnerTargetDir
Expand Down

0 comments on commit 2a24cca

Please sign in to comment.