codekingpro/portable-devtools
115k
1const is = require('./is.js')
2const { dirname } = require('path')
3
4module.exports = async ({ cwd = process.cwd(), root } = {}) => {
5 while (true) {
6 if (await is({ cwd })) {
7 return cwd
8 }
9 const next = dirname(cwd)
10 if (cwd === root || cwd === next) {
11 return null
12 }
13 cwd = next
14 }
15}
16 