2023-03-19 17:37:07 +02:00
|
|
|
import execCommand from './execCommand';
|
|
|
|
import commandToString from './commandToString';
|
|
|
|
import splitCommandString from './splitCommandString';
|
2023-03-19 19:31:37 +02:00
|
|
|
import { dirname } from 'path';
|
2023-04-05 22:27:26 +02:00
|
|
|
import { pathExists } from 'fs-extra';
|
2023-03-19 19:31:37 +02:00
|
|
|
|
2023-04-05 22:27:26 +02:00
|
|
|
let rootDir_ = '';
|
|
|
|
|
2023-07-16 18:48:13 +02:00
|
|
|
|
2023-04-05 22:27:26 +02:00
|
|
|
const getRootDir = async () => {
|
|
|
|
if (rootDir_) return rootDir_;
|
|
|
|
|
|
|
|
let p = dirname(dirname(dirname(__dirname)));
|
|
|
|
for (let i = 0; i < 9999; i++) {
|
|
|
|
if (await pathExists(`${p}/.eslintrc.js`)) {
|
|
|
|
rootDir_ = p;
|
|
|
|
return rootDir_;
|
|
|
|
}
|
|
|
|
p = dirname(p);
|
|
|
|
}
|
|
|
|
throw new Error('Could not find root dir');
|
|
|
|
};
|
2023-03-19 17:37:07 +02:00
|
|
|
|
|
|
|
export {
|
|
|
|
execCommand,
|
|
|
|
commandToString,
|
|
|
|
splitCommandString,
|
2023-04-05 22:27:26 +02:00
|
|
|
getRootDir,
|
2023-03-19 17:37:07 +02:00
|
|
|
};
|