Skip to content

Commit

Permalink
fix(top-level): support git submodules (#784)
Browse files Browse the repository at this point in the history
* fix: modify the parameters for the sander.readFile function (#448)

* fix: modify the parameters for the sander.readFile function (#448) - prettier lint fix

* fix: do NOT specify the .git to be a directory in case of the git submodule not able to work properly

* fix: add a new function 'searchDotGit' to make sure we can find a correct .git path which can be file or directory (#784)
  • Loading branch information
huanghai21 authored and marionebl committed Oct 21, 2019
1 parent 492d330 commit 9d09693
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion @commitlint/top-level/src/index.ts
Expand Up @@ -14,11 +14,21 @@ export default toplevel;
* Find the next git root
*/
async function toplevel(cwd: string) {
const found = await up('.git', {cwd, type: 'directory'});
const found = await searchDotGit(cwd);

if (typeof found !== 'string') {
return found;
}

return path.join(found, '..');
}

/**
* Search .git, the '.git' can be a file(submodule), also can be a directory(normal)
*/
async function searchDotGit(cwd: string) {
const foundFile = await up('.git', {cwd, type: 'file'});
const foundDir = await up('.git', {cwd, type: 'directory'});

return foundFile || foundDir;
}

0 comments on commit 9d09693

Please sign in to comment.