Skip to content

Commit

Permalink
fix: env find package
Browse files Browse the repository at this point in the history
  • Loading branch information
zdm committed Mar 27, 2024
1 parent 7b61a57 commit 88bd4df
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 22 deletions.
4 changes: 0 additions & 4 deletions lib/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ export default class {
return Package.findRootPackage( dir );
}

_isPackageDir ( dir ) {
return Package.isPackageDir( dir );
}

_isRootPackageDir ( dir ) {
return Package.isRootPackageDir( dir );
}
Expand Down
24 changes: 6 additions & 18 deletions lib/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,28 +46,16 @@ export default class Package {
return fs.existsSync( dir + "/package.json" ) && fs.existsSync( dir + "/.git" );
}

static findRootPackage ( path ) {
var root = _path.normalize( _path.resolve( path || process.cwd() ) );
static findRootPackage ( root ) {
root = env.findGitPackageRoot( root );

while ( 1 ) {
if ( this.isRootPackageDir( root ) ) return new this( root.replaceAll( "\\", "/" ) );

if ( _path.dirname( root ) === root ) break;

root = _path.dirname( root );
}
if ( root ) return new this( root.replaceAll( "\\", "/" ) );
}

static findNearestPackage ( path ) {
var root = _path.normalize( _path.resolve( path || process.cwd() ) );
static findNearestPackage ( root ) {
root = env.findPackageRoot( root );

while ( 1 ) {
if ( this.isPackageDir( root ) ) return new this( root.replaceAll( "\\", "/" ) );

if ( _path.dirname( root ) === root ) break;

root = _path.dirname( root );
}
if ( root ) return new this( root.replaceAll( "\\", "/" ) );
}

// props
Expand Down

0 comments on commit 88bd4df

Please sign in to comment.