mirror of
https://github.com/nodejs/node.git
synced 2025-05-13 07:34:30 +00:00

PR-URL: https://github.com/nodejs/node/pull/38254 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
16 lines
300 B
JavaScript
16 lines
300 B
JavaScript
const is = require('./is.js')
|
|
const { dirname } = require('path')
|
|
|
|
module.exports = async ({ cwd = process.cwd() } = {}) => {
|
|
if (await is({ cwd })) {
|
|
return cwd
|
|
}
|
|
while (cwd !== dirname(cwd)) {
|
|
cwd = dirname(cwd)
|
|
if (await is({ cwd })) {
|
|
return cwd
|
|
}
|
|
}
|
|
return null
|
|
}
|