function findPackages(p = 'node_modules') {
        if (!isDirectory(p)) {
            return [];
        }
        const pkgs = [];
        const listing = fs.readdirSync(p);
        const packages = listing
            // filter out scopes
            .filter(f => !f.startsWith('@'))
            // filter out folders such as `.bin` which can create
            // issues on Windows since these are "hidden" by default
            .filter(f => !f.startsWith('.'))
            .map(f => path.posix.join(p, f))
            .filter(f => isDirectory(f));
        packages.forEach(f => {
            let hide = true;
            if (fs.lstatSync(f).isSymbolicLink()) {
                hide = false;
            }
            pkgs.push(parsePackage(f, hide), ...findPackages(path.posix.join(f, 'node_modules')));
        });
        const scopes = listing.filter(f => f.startsWith('@'))
            .map(f => path.posix.join(p, f))
            .filter(f => isDirectory(f));
        scopes.forEach(f => pkgs.push(...findPackages(f)));
        return pkgs;
    }
/**
     * Finds and returns an array of all packages under a given path.
     */
Finds and returns an array of all packages under a given path.
Finds and returns an array of all packages under a given path .
function findPackages(p = 'node_modules') {
        if (!isDirectory(p)) {
            return [];
        }
        const pkgs = [];
        const listing = fs.readdirSync(p);
        const packages = listing
            .filter(f => !f.startsWith('@'))
            .filter(f => !f.startsWith('.'))
            .map(f => path.posix.join(p, f))
            .filter(f => isDirectory(f));
        packages.forEach(f => {
            let hide = true;
            if (fs.lstatSync(f).isSymbolicLink()) {
                hide = false;
            }
            pkgs.push(parsePackage(f, hide), ...findPackages(path.posix.join(f, 'node_modules')));
        });
        const scopes = listing.filter(f => f.startsWith('@'))
            .map(f => path.posix.join(p, f))
            .filter(f => isDirectory(f));
        scopes.forEach(f => pkgs.push(...findPackages(f)));
        return pkgs;
    }
function findPackages ( p = 'node_modules' ) { if ( ! isDirectory ( p ) ) { return [ ] ; } const pkgs = [ ] ; const listing = fs . readdirSync ( p ) ; const packages = listing . filter ( f => ! f . startsWith ( '@' ) ) . filter ( f => ! f . startsWith ( '.' ) ) . map ( f => path . posix . join ( p , f ) ) . filter ( f => isDirectory ( f ) ) ; packages . forEach ( f => { let hide = true ; if ( fs . lstatSync ( f ) . isSymbolicLink ( ) ) { hide = false ; } pkgs . push ( parsePackage ( f , hide ) , ... findPackages ( path . posix . join ( f , 'node_modules' ) ) ) ; } ) ; const scopes = listing . filter ( f => f . startsWith ( '@' ) ) . map ( f => path . posix . join ( p , f ) ) . filter ( f => isDirectory ( f ) ) ; scopes . forEach ( f => pkgs . push ( ... findPackages ( f ) ) ) ; return pkgs ; }
Finds and returns an array of all packages under a given path.
Finds and returns an array of all packages under a given path .
// filter out scopes // filter out folders such as `.bin` which can create // issues on Windows since these are "hidden" by default