Skip to content

Commit

Permalink
Fix: Handle Windows path separators when calculating base path on Win…
Browse files Browse the repository at this point in the history
…dows (fixes #68) (#69)
  • Loading branch information
doowb authored and phated committed Feb 21, 2017
1 parent 353a810 commit 40128d6
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
27 changes: 27 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Test against these versions of Node.js
environment:
matrix:
# node.js
- nodejs_version: "6.0"
- nodejs_version: "5.0"
- nodejs_version: "4.0"
- nodejs_version: "0.12"
- nodejs_version: "0.10"

# Install scripts. (runs after repo cloning)
install:
# Get the latest stable version of Node.js or io.js
- ps: Install-Product node $env:nodejs_version
# install modules
- npm install

# Post-install test scripts.
test_script:
# Output useful info for debugging.
- node --version
- npm --version
# run tests
- npm test

# Don't actually build.
build: off
15 changes: 14 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var resolveGlob = require('to-absolute-glob');
var globParent = require('glob-parent');
var path = require('path');
var extend = require('extend');
var sepRe = (process.platform === 'win32' ? /[\/\\]/ : /\/+/);

var gs = {
// Creates a stream for a single glob or filter
Expand Down Expand Up @@ -190,7 +191,19 @@ function globIsSingular(glob) {
}

function getBasePath(ourGlob, opt) {
return resolveGlob(globParent(ourGlob) + path.sep, opt);
var basePath;
var parent = globParent(ourGlob);

if (parent === '/' && opt && opt.root) {
basePath = path.normalize(opt.root);
} else {
basePath = resolveGlob(parent, opt);
}

if (!sepRe.test(basePath.charAt(basePath.length - 1))) {
basePath += path.sep;
}
return basePath;
}

module.exports = gs;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"index.js"
],
"scripts": {
"lint": "eslint . && jscs *.js test/",
"lint": "eslint . && jscs . test/",
"pretest": "npm run lint",
"test": "mocha",
"coveralls": "istanbul cover _mocha --report lcovonly && istanbul-coveralls"
Expand Down

0 comments on commit 40128d6

Please sign in to comment.