Browse Source

Fix paths in win

pull/1785/head
jlukic 10 years ago
parent
commit
a7c6cd3384
2 changed files with 15 additions and 16 deletions
  1. 25
      tasks/config/project/config.js
  2. 6
      tasks/config/project/install.js

25
tasks/config/project/config.js

@ -19,34 +19,33 @@ module.exports = {
getPath: function(file, directory) { getPath: function(file, directory) {
var var
configPath = '',
configPath,
walk = function(directory) { walk = function(directory) {
var var
currentPath = path.normalize( path.join(directory, file) )
nextDirectory = path.resolve( path.join(directory, path.sep, '..') ),
currentPath = path.normalize( path.join(directory, file) )
; ;
if( fs.existsSync(currentPath) ) { if( fs.existsSync(currentPath) ) {
// found file // found file
configPath = path.normalize(directory);
return true;
configPath = path.normalize(currentPath);
return;
} }
else { else {
// reached file system root, let's stop // reached file system root, let's stop
if(path.resolve(directory) == path.sep) {
return false;
if(nextDirectory == directory) {
return;
} }
// otherwise recurse // otherwise recurse
walk(directory + '..' + path.sep, file);
walk(nextDirectory, file);
} }
} }
; ;
file = file || defaults.files.config;
directory = directory || __dirname + '/..';
// start walk from outside require-dot-files directory
file = file || defaults.files.config;
directory = directory || path.join(__dirname, path.sep, '..');
walk(directory); walk(directory);
return configPath;
return configPath || '';
}, },
// adds additional derived values to a config object // adds additional derived values to a config object

6
tasks/config/project/install.js

@ -90,7 +90,7 @@ module.exports = {
var var
pathArray = directory.split('/'), pathArray = directory.split('/'),
folder = pathArray[pathArray.length - 2], folder = pathArray[pathArray.length - 2],
nextDirectory = path.normalize(directory + '/../')
nextDirectory = path.join(directory + '..')
; ;
if( folder == 'bower_components') { if( folder == 'bower_components') {
return { return {
@ -110,7 +110,7 @@ module.exports = {
root: nextDirectory root: nextDirectory
}; };
} }
if(path.resolve(directory) == '/') {
if(path.resolve(directory) == path.resolve(nextDirectory)) {
return false; return false;
} }
// recurse downward // recurse downward
@ -118,7 +118,7 @@ module.exports = {
} }
; ;
// start walk from current directory if none specified // start walk from current directory if none specified
directory = directory || (__dirname + '/');
directory = directory || (__dirname + path.sep);
return walk(directory); return walk(directory);
}, },

Loading…
Cancel
Save