Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Find TypeScript Declarations

Find packages containing TypeScript declarations.

Usage

var findTypes = require( '@stdlib/_tools/pkgs/types' );

findTypes( [options,] clbk )

Asynchronously searches for packages containing TypeScript declarations.

findTypes( onPkgs );

function onPkgs( error, pkgs ) {
    if ( error ) {
        throw error;
    }
    console.log( pkgs.join( '\n' ) );
}

The function accepts the following options:

  • dir: root directory from which to search for packages containing TypeScript declarations. May be either an absolute path or a path relative to the current working directory. Default: current working directory.
  • pattern: glob pattern used to find packages containing TypeScript declarations. Default: '**/package.json' (note: pattern must end with package.json).
  • ignore: list of glob patterns used to exclude matches.

To search from an alternative directory, set the dir option.

var opts = {
    'dir': '/foo/bar/baz'
};

findTypes( opts, onPkgs );

function onPkgs( error, pkgs ) {
    if ( error ) {
        throw error;
    }
    console.log( pkgs.join( '\n' ) );
}

To provide an alternative include filter, set the pattern option.

var opts = {
    'pattern': '**/foo/**/package.json'
};

findTypes( opts, onPkgs );

function onPkgs( error, pkgs ) {
    if ( error ) {
        throw error;
    }
    console.log( pkgs.join( '\n' ) );
}

To exclude matches, set the ignore option.

var opts = {
    'ignore': [
        'node_modules/**',
        'build/**',
        'reports/**'
    ]
};

findTypes( opts, onPkgs );

function onPkgs( error, pkgs ) {
    if ( error ) {
        throw error;
    }
    console.log( pkgs.join( '\n' ) );
}

findTypes.sync( [options] )

Synchronously searches for packages containing TypeScript declarations.

var pkgs = findTypes.sync();
// returns [...]

The function accepts the same options as findTypes() above.

Notes

  • The implementation resolves packages containing TypeScript declarations by checking for a types field in a package's package.json file.
  • No attempt is made to ensure that TypeScript declarations are actually exposed by the package.

Examples

var findTypes = require( '@stdlib/_tools/pkgs/types' );

findTypes( onPkgs );

function onPkgs( error, pkgs ) {
    if ( error ) {
        throw error;
    }
    console.log( pkgs.join( '\n' ) );
}

CLI

Usage

Usage: find-pkg-types [options] [<dir>]

Options:

  -h,    --help                Print this message.
  -V,    --version             Print the package version.
         --pattern pattern     Inclusion glob pattern.
         --ignore pattern      Exclusion glob pattern.

Notes

  • If not provided a dir argument, the current working directory is the search directory.

  • To provide multiple exclusion glob patterns, set multiple --ignore option arguments.

    $ find-pkg-types --ignore=node_modules/** --ignore=build/** --ignore=reports/**

Examples

$ find-pkg-types
<pkg>
<pkg>
...