mirror of
https://github.com/nodejs/node.git
synced 2025-08-18 15:18:46 +02:00

PR-URL: https://github.com/nodejs/node/pull/48378 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Luke Karrys <luke@lukekarrys.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
15 lines
316 B
JavaScript
15 lines
316 B
JavaScript
const is = require('./is.js')
|
|
const { dirname } = require('path')
|
|
|
|
module.exports = async ({ cwd = process.cwd(), root } = {}) => {
|
|
while (true) {
|
|
if (await is({ cwd })) {
|
|
return cwd
|
|
}
|
|
const next = dirname(cwd)
|
|
if (cwd === root || cwd === next) {
|
|
return null
|
|
}
|
|
cwd = next
|
|
}
|
|
}
|