Skip to content
This repository has been archived by the owner on Apr 1, 2023. It is now read-only.

Commit

Permalink
Search for version control systems as project indicators. Fixes #519
Browse files Browse the repository at this point in the history
  • Loading branch information
robertpark committed Mar 4, 2015
1 parent ad4ced4 commit b43e2a9
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions app/js/fs/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,29 @@ define(function(require, exports, module) {

// Support opening a single file
var stats = nodeFs.statSync(rootPath);
var filename;
var filename, newRoot, vcsStat;
if (stats.isFile()) {
filename = path.basename(rootPath);
rootPath = path.dirname(rootPath);
var vcsFound = false;
filename = rootPath;
do {
// Scan up the file tree looking for version control dirs.
newRoot = path.dirname(rootPath);
if (newRoot == rootPath) {
// No VCS found, give up.
rootPath = path.dirname(filename);
break;
} else {
rootPath = newRoot;
}
[".bzr", ".git", ".svn", ".hg", ".fslckout", "_darcs", "CVS"].some(function(vcs) {
try {
vcsStat = nodeFs.statSync(path.join(rootPath, vcs));
vcsFound = true;
return true;
} catch(ignore) {}
});
} while (!vcsFound);
filename = stripRoot(filename).slice(1);
}

// Copy and paste from project.js, but cannot important that due to
Expand Down

0 comments on commit b43e2a9

Please sign in to comment.