mirror of
https://github.com/garronej/ts-ci.git
synced 2025-12-01 05:43:06 +00:00
initial commit
This commit is contained in:
parent
a55f9e86eb
commit
e0de45950f
3 changed files with 65 additions and 8 deletions
23
src/tools/getProjectRoot.ts
Normal file
23
src/tools/getProjectRoot.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
|
||||
|
||||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
|
||||
function getProjectRootRec(dirPath: string){
|
||||
if( fs.existSync(path.join(dirPath, "package.json")) ){
|
||||
return dirPath;
|
||||
}
|
||||
return getProjectRootRec(path.join(dirPath, ".."))
|
||||
}
|
||||
|
||||
let result: string | undefined = undefined;
|
||||
|
||||
export function getProjectRoot(): string{
|
||||
|
||||
if( result !== undefined ){
|
||||
return result;
|
||||
}
|
||||
|
||||
return result = getProjectRootRec(__dirname);
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue