Resolve package entry points.
var entryPoints = require( '@stdlib/tools/pkgs/entry-points' );Asynchronously resolves package entry points.
var pkgs = [ 'tape', 'browserify' ];
entryPoints( pkgs, onEntries );
function onEntries( error, entries ) {
if ( error ) {
throw error;
}
console.dir( entries );
}Each package is represented by an object having the following fields:
- id: package identifier.
- pkg: package name, as specified in
pkgs. - dir: package directory.
- entries: an
arrayof package entry points.
The function accepts the following options:
- dir: root directory from which to resolve packages. May be either an absolute file path or a path relative to the current working directory.
By default, the function resolves packages relative to the current working directory. To resolve relative to an alternative directory, set the dir option.
var opts = {
'dir': '/foo/bar/baz'
};
var pkgs = [ 'tape', 'browserify' ];
entryPoints( pkgs, opts, onEntries );
function onEntries( error, entries ) {
if ( error ) {
throw error;
}
console.dir( entries );
}Synchronously resolves package entry points.
var pkgs = [ 'tape', 'browserify' ];
var entries = entryPoints.sync( pkgs );
// returns [...]The function accepts the same options as entryPoints() above.
var resolve = require( 'path' ).resolve;
var entryPoints = require( '@stdlib/tools/pkgs/entry-points' );
var pkg = resolve( __dirname, '../' );
var pkgs = [ pkg, 'tape' ];
entryPoints( pkgs, onEntries );
function onEntries( error, results ) {
if ( error ) {
throw error;
}
console.dir( results );
}Usage: pkg-entry-points [options] [<pkg> <pkg> <pkg> ...]
Options:
-h, --help Print this message.
-V, --version Print the package version.
--dir dir Base directory.
--split sep Separator for standard input data. Default: '/\r?\n/'.-
If the split separator is a regular expression, ensure that the
splitoption is properly escaped.# Not escaped... $ echo -n $'tape\nbrowsery\n' | pkg-entry-points --split /\r?\n/ # Escaped... $ echo -n $'tape\nbrowserify\n' | pkg-entry-points --split /\\r?\\n/
-
Results are printed to
stdoutas newline-delimited JSON (NDJSON).
$ pkg-entry-points tape browserify
{...}
{...}$ echo -n $'tape\nbrowserify\n' | pkg-entry-points --split /\\r?\\n/
{...}
{...}