Generate a stdlib package tree.
var pkgTree = require( '@stdlib/_tools/pkgs/tree' );Asynchronously generates a package tree.
pkgTree( onTree );
function onTree( error, tree ) {
if ( error ) {
throw error;
}
console.dir( tree );
}The function accepts the following options:
- dir: root directory from which to search for packages. May be either an absolute path or a path relative to the
stdlib/lib/node_modules/directory. Default:/path/to/stdlib/lib/node_modules/. - pattern: glob pattern used to find packages. Default:
'**/package.json'(note: pattern must end withpackage.json). - ignore: list of glob patterns used to exclude matches.
To search from a descendant directory, set the dir option.
var opts = {
'dir': './@stdlib/math/base'
};
pkgTree( opts, onTree );
function onTree( error, tree ) {
if ( error ) {
throw error;
}
console.dir( tree );
}To provide an alternative include filter, set the pattern option.
var opts = {
'pattern': '**/foo/**/package.json'
};
pkgTree( opts, onTree );
function onTree( error, tree ) {
if ( error ) {
throw error;
}
console.dir( tree );
}To exclude matches, set the ignore option.
var opts = {
'ignore': [
'node_modules/**',
'build/**',
'reports/**',
'foo/**'
]
};
pkgTree( opts, onTree );
function onTree( error, tree ) {
if ( error ) {
throw error;
}
console.dir( tree );
}Synchronously generates a package tree.
var tree = pkgTree.sync();
// returns {...}The function accepts the same options as pkgTree() above.
- Both functions only return packages under the
@stdlibscope. - Both functions always ignore
examples/fixtures,test/fixtures, andbenchmark/fixturesdirectories, irrespective of whether anignoreoption is provided.
var pkgTree = require( '@stdlib/_tools/pkgs/tree' );
pkgTree( onTree );
function onTree( error, tree ) {
if ( error ) {
throw error;
}
console.dir( tree );
}Usage: stdlib-pkg-tree [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 search directory is the current working directory. -
To provide multiple exclusion glob patterns, set multiple
--ignoreoption arguments.$ stdlib-pkg-tree --ignore=node_modules/** --ignore=build/** --ignore=reports/**
$ stdlib-pkg-tree