fix(cli): failed to find root dir (#7755)

This commit is contained in:
neverland 2020-12-16 20:23:36 +08:00 committed by GitHub
parent 27cf2d60ef
commit 4af658e67a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,15 +3,16 @@ import { existsSync } from 'fs-extra';
import { join, dirname, isAbsolute } from 'path';
function findRootDir(dir: string): string {
if (dir === '/') {
return '/';
}
if (existsSync(join(dir, 'vant.config.js'))) {
return dir;
}
return findRootDir(dirname(dir));
const parentDir = dirname(dir);
if (dir === parentDir) {
return dir;
}
return findRootDir(parentDir);
}
// Colors