-
-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Windows path separator #69
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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.join(opt.root); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would this be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, |
||
} else { | ||
basePath = resolveGlob(parent, opt); | ||
} | ||
|
||
if (!sepRe.test(basePath.charAt(basePath.length - 1))) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it better to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is testing the last character better than a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is more habit for me with strings since it differentiates them from other arrays. I also read that it was faster in node. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think so because I don't think regex will start from the end of a string and test backwards so it'll be testing all the possible combinations leading up to the end. By only testing the last character, it reduces the amount of characters that the regex has to go through. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's weird that RegExps with the "ends with" character would search the whole string. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I thought that too, but this talk is where I learned more about regexp. I'm assuming that it works this way when using If I find the time, I may put together some benchmarks with these patterns. |
||
basePath += path.sep; | ||
} | ||
return basePath; | ||
} | ||
|
||
module.exports = gs; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this be
new RegExp(path.sep)
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For
win32
it's checking for either/
or\
and replacing with thepath.sep
. This is because the user might have passed in/
on windows in their glob pattern.