diff --git a/projects/js-packages/jetpack-cli/bin/jp.js b/projects/js-packages/jetpack-cli/bin/jp.js index 132c9e2d1e77d..0ccfaeaab8fc1 100755 --- a/projects/js-packages/jetpack-cli/bin/jp.js +++ b/projects/js-packages/jetpack-cli/bin/jp.js @@ -50,10 +50,13 @@ const isMonorepoRoot = dir => { */ const findMonorepoRoot = startDir => { let dir = startDir; - while ( dir !== '/' ) { + let prevDir; + while ( dir !== prevDir ) { + // Keep going until dirname() stops changing the path if ( isMonorepoRoot( dir ) ) { return dir; } + prevDir = dir; dir = dirname( dir ); } return null;