File size: 432 Bytes
d0aa19c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { normalize } from 'path';

const rootDirFinder = function(): string {
	const parts = __dirname.split('/');
	let level = parts.length - 1;
	while (level > 0) {
		const currentPath = parts.slice(0, level).join('/');
		try {
			require(`${currentPath}/package.json`);
			return currentPath;
		} catch (err) { }
		level --;
	}
	return "";
};
const __rootDir: string = normalize(rootDirFinder()+'/..');

export default __rootDir;