Skip to content
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

fix custom comiler file (absolute path) support in windows system #2329

Merged
merged 2 commits into from
Jul 1, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions bin/_mocha
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,9 @@ if (program.retries) mocha.suite.retries(program.retries);

var extensions = ['js'];
program.compilers.forEach(function(c) {
var compiler = c.split(':')
, ext = compiler[0]
, mod = compiler[1];
var compiler = c.match(/([a-z.]+):(([A-Z]:)?\S*)+/)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are several problems with this regular expression--instead, try c.split(':', 1). does that work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@boneskull

var str = 'js:C:\\Users\\fortest\\example\\compiler.js';
console.log(str.split(':', 1))
//['js']

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, it still splits, just doesn't return it. how about just:

var idx = c.indexOf(':');
var ext = c.slice(0, idx);
var mod = c.slice(idx + 1);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"slice" is better, I will update this PR

, ext = compiler[1]
, mod = compiler[2];

if (mod[0] == '.') mod = join(process.cwd(), mod);
require(mod);
Expand Down