Find package command-line interfaces (CLIs).
var findCLIs = require( '@stdlib/_tools/pkgs/clis' );Asynchronously searches for package command-line interfaces.
findCLIs( onCLIs );
function onCLIs( error, files ) {
if ( error ) {
throw error;
}
console.log( files.join( '\n' ) );
}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 current working directory. Default: current working directory.
- 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 an alternative directory, set the dir option.
var opts = {
'dir': '/foo/bar/baz'
};
findCLIs( opts, onCLIs );
function onCLIs( error, files ) {
if ( error ) {
throw error;
}
console.log( files.join( '\n' ) );
}To provide an alternative include filter, set the pattern option.
var opts = {
'pattern': '**/foo/**/package.json'
};
findCLIs( opts, onCLIs );
function onCLIs( error, files ) {
if ( error ) {
throw error;
}
console.log( files.join( '\n' ) );
}To exclude matches, set the ignore option.
var opts = {
'ignore': [
'node_modules/**',
'build/**',
'reports/**'
]
};
findCLIs( opts, onCLIs );
function onCLIs( error, files ) {
if ( error ) {
throw error;
}
console.log( files.join( '\n' ) );
}Synchronously searches for package command-line interfaces.
var files = findCLIs.sync();
// returns [...]The function accepts the same options as findCLIs() above.
- The implementation resolves command-line interfaces by reading
package.jsonfiles and resolving paths found in thebinfield. - No attempt is made to ensure that a command-line interface file exists.
- The implementation assumes that a
binfield is valid; i.e., either astringor anobject.
var findCLIs = require( '@stdlib/_tools/pkgs/clis' );
findCLIs( onCLIs );
function onCLIs( error, files ) {
if ( error ) {
throw error;
}
console.log( files.join( '\n' ) );
}Usage: find-pkg-clis [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-clis --ignore=node_modules/** --ignore=build/** --ignore=reports/**
$ find-pkg-clis
<filepath>
<filepath>
...