Merge pull request #755 from bower/win-paths-normalize

Normalise windows paths, closes #279.
This commit is contained in:
André Cruz
2013-08-11 06:49:37 -07:00

View File

@@ -17,20 +17,25 @@ function list(options, config) {
project.getTree()
.spread(function (tree, flattened) {
var baseDir;
var baseDir = path.dirname(path.join(config.cwd, config.directory));
// Relativize?
if (options.relative) {
baseDir = path.dirname(path.join(config.cwd, config.directory));
project.walkTree(tree, function (node) {
// Relativize paths
// Also normalize paths on windows
project.walkTree(tree, function (node) {
if (options.relative) {
node.canonicalDir = path.relative(baseDir, node.canonicalDir);
}, true);
}
node.canonicalDir = normalize(node.canonicalDir);
}, true);
mout.object.forOwn(flattened, function (node) {
// Note that we need to to parse the flattened tree because it might
// contain additional packages
mout.object.forOwn(flattened, function (node) {
if (options.relative) {
node.canonicalDir = path.relative(baseDir, node.canonicalDir);
});
}
}
node.canonicalDir = normalize(node.canonicalDir);
});
// Render paths?
if (options.paths) {
@@ -119,7 +124,7 @@ function paths(flattened) {
// Concatenate each main entry with the canonical dir
main = main.map(function (part) {
return path.join(pkg.canonicalDir, part).trim();
return normalize(path.join(pkg.canonicalDir, part).trim());
}).join(',');
ret[name] = main;
@@ -128,6 +133,10 @@ function paths(flattened) {
return ret;
}
function normalize(src) {
return src.replace(/\\/g, '/');
}
// -------------------
list.line = function (argv) {