Skip to content

Commit ab6dbfb

Browse files
committed
Remove path.relative() which produce unexpected results on Windows
1 parent f784a39 commit ab6dbfb

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

tasks/examples.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
var path = require('path');
21
var _ = require('lodash');
32

43
function pathToArray(parts) {
@@ -34,11 +33,10 @@ module.exports = function(grunt) {
3433
grunt.log.warn('Source file "' + filepath + '" not found.');
3534
return false;
3635
} else {
37-
filepath = path.relative(options.base, filepath);
3836
return options.excludes.every(function(dir) {
39-
var keep = filepath.indexOf(dir + '/') < 0;
37+
var keep = filepath.indexOf(options.base + '/' + dir + '/') < 0;
4038
if (!keep) {
41-
grunt.verbose.writeln('Skipping %s%s...', (dir + '/').inverse.red, filepath.substr(dir.length + 1));
39+
grunt.verbose.writeln('Skipping %s/%s/%s...', options.base, dir.inverse.red, filepath.substr(options.base.length + dir.length + 2));
4240
}
4341
return keep;
4442
});
@@ -54,7 +52,7 @@ module.exports = function(grunt) {
5452
}
5553

5654
files.map(function(filepath) {
57-
return pathToArray(path.relative(options.base, filepath).split('/'));
55+
return pathToArray(filepath.substr(options.base.length + 1).split('/'));
5856
}).forEach(function(parts) {
5957
_.merge(results, parts, function(a, b) {
6058
var example = {

0 commit comments

Comments
 (0)