diff --git a/lib/command.js b/lib/command.js index 822d4bce..bb5761fd 100644 --- a/lib/command.js +++ b/lib/command.js @@ -21,10 +21,6 @@ export default class { return Package.findRootPackage( dir ); } - _isPackageDir ( dir ) { - return Package.isPackageDir( dir ); - } - _isRootPackageDir ( dir ) { return Package.isRootPackageDir( dir ); } diff --git a/lib/package.js b/lib/package.js index 2bf55922..7feb52e4 100644 --- a/lib/package.js +++ b/lib/package.js @@ -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