Find packages containing TypeScript declarations.
var findTypes = require( '@stdlib/_tools/pkgs/types' );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 withpackage.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' ) );
}Synchronously searches for packages containing TypeScript declarations.
var pkgs = findTypes.sync();
// returns [...]The function accepts the same options as findTypes() above.
- The implementation resolves packages containing TypeScript declarations by checking for a
typesfield in a package'spackage.jsonfile. - No attempt is made to ensure that TypeScript declarations are actually exposed by the package.
var findTypes = require( '@stdlib/_tools/pkgs/types' );
findTypes( onPkgs );
function onPkgs( error, pkgs ) {
if ( error ) {
throw error;
}
console.log( pkgs.join( '\n' ) );
}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.
-
If not provided a
dirargument, the current working directory is the search directory. -
To provide multiple exclusion glob patterns, set multiple
--ignoreoption arguments.$ find-pkg-types --ignore=node_modules/** --ignore=build/** --ignore=reports/**
$ find-pkg-types
<pkg>
<pkg>
...