Skip to content

Commit

Permalink
Package.js:api.addFiles and Assets.get* accept both type of paths
Browse files Browse the repository at this point in the history
  • Loading branch information
Slava authored and Sashko Stubailo committed Jan 21, 2015
1 parent 67529ce commit 296d765
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tools/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -1375,3 +1375,8 @@ files.pathwatcherWatch = function () {

files.convertToStandardPath = convertToStandardPath;
files.convertToOSPath = convertToOSPath;
<<<<<<< HEAD
=======
files.convertToPosixPath = toPosixPath;

>>>>>>> Package.js:api.addFiles and Assets.get* accept both type of paths
12 changes: 12 additions & 0 deletions tools/package-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -1220,6 +1220,18 @@ _.extend(PackageSource.prototype, {
paths = toArray(paths);
arch = toArchArray(arch);

// Convert Dos-style paths to Unix-style paths.
// XXX it is possible to convert an already Unix-style path by mistake
// and break it. e.g.: 'some\folder/anotherFolder' is a valid path
// consisting of two components. #WindowsPathApi
paths = _.map(paths, function (p) {
if (p.indexOf('/') !== -1) {
// it is already a Unix-style path most likely
return p;
}
return files.convertToPosixPath(p, true);
});

_.each(paths, function (path) {
forAllMatchingArchs(arch, function (a) {
var source = {relPath: path};
Expand Down
9 changes: 9 additions & 0 deletions tools/server/boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,15 @@ Fiber(function () {
console.log("Exception in callback of getAsset", e.stack);
});

// Convert a DOS-style path to Unix-style in case the application code was
// written on Windows.
// XXX note that we can't always correctly convert #WindowsPathApi
if (assetPath.indexOf('/') !== -1) {
// it is already a Unix-style path most likely
} else {
assetPath = assetPath.replace(/\\/g, '/');
}

if (!fileInfo.assets || !_.has(fileInfo.assets, assetPath)) {
_callback(new Error("Unknown asset: " + assetPath));
} else {
Expand Down

0 comments on commit 296d765

Please sign in to comment.