Skip to content

Commit

Permalink
Generated module paths should respect windows systems (fix #274)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladimir Varankin committed Nov 10, 2013
1 parent 9ad7396 commit c539b69
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions .bem/techs/node.js.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
var PATH = require('path');

exports.baseTechName = 'vanilla.js';

exports.techMixin = {
Expand Down Expand Up @@ -29,12 +31,18 @@ exports.techMixin = {
].join('');
},

getBuildResultChunk : function(relPath, path) {
var fChar = relPath.charAt(0);
if(fChar !== '/' && fChar !== '.') {
getBuildResultChunk : function(relPath) {
// NOTE: module's path is always an UNIX path,
// so `relPath` should be converted on Windows systems
if(PATH.sep !== '/') {
relPath = relPath.replace(/\\/g, '/');
}
// NOTE: Without a leading '/' or './' to indicate a file, the module is either
// a "core module" or is loaded from a node_modules folder
if(/^\w/.test(relPath)) {
relPath = './' + relPath;
}
return "require('" + relPath + "');\n";
return 'require(\'' + relPath + '\');\n';
}

};
};

0 comments on commit c539b69

Please sign in to comment.