/es-deps-resolved

ECMAScript 2015+/CommonJS module dependencies resolved array

Primary LanguageJavaScript

es-deps-resolved

NPM version Build Status Coveralls Status Dependency Status

ECMAScript 2015+/CommonJS module dependencies resolved array

Install

npm install --save es-deps-resolved

Usage

import path from 'path';
import esDepsResolved from 'es-deps-resolved';

/* fixtures/index.js
import fileResolved from './local';
import fileUnresolved from './local-extra';

import folderResolved from './folder';
import folderUnresolved from './folder-extra';

import pkgResolved from 'pkg';
import pkgUnresolved from 'pkg-extra';
*/

esDepsResolved(path.join(__dirname, './fixtures'))
  .then(result => console.log(result)); /* [
    { requested: './local', resolved: '/Users/iamstarkov/projects/es-deps-resolved/fixtures/local.js'
      from: '/Users/iamstarkov/projects/es-deps-resolved/fixtures/index.js' },
    { requested: './local-extra', resolved: null,
      from: '/Users/iamstarkov/projects/es-deps-resolved/fixtures/index.js' },
    { requested: './folder', resolved: '/Users/iamstarkov/projects/es-deps-resolved/fixtures/folder/index.js',
      from: '/Users/iamstarkov/projects/es-deps-resolved/fixtures/index.js' },
    { requested: './folder-extra', resolved: null,
      from: '/Users/iamstarkov/projects/es-deps-resolved/fixtures/index.js' },
    { requested: 'pkg', resolved: '/Users/iamstarkov/projects/es-deps-resolved/fixtures/node_modules/pkg/index.js',
      from: '/Users/iamstarkov/projects/es-deps-resolved/fixtures/index.js' },
    { requested: 'pkg-extra', resolved: null,
      from: '/Users/iamstarkov/projects/es-deps-resolved/fixtures/index.js' } ] */

esDepsResolved(path.join(__dirname, './fixtures-unexistent'))
  .catch(reason => console.error(reason)); // new Error("Can't find and open `./fixtures-unexistent`")

API

esDepsResolved(file)

Returns Promise which resolved to Array[Object]:

Array[Object {
  requested: String,
  from: String,
  resolved: String | null /* `null` if dependency is not resolvable */
}]

file

Required
Type: String

Absolute path.

Related

  • es-deps — ECMAScript 2015+/CommonJS module dependencies array
  • es-deps-from-string — ECMAScript 2015+/CommonJS module dependencies array from string
  • es-dep-unit — Constructor for ECMAScript 2015+/CommonJS dependency unit Object { requested, from, resolved }
  • es-deps-deep — ECMAScript 2015+/CommonJS module dependencies resolved in depth
  • es-dep-kit — ECMAScript 2015+/CommonJS module dependencies helpers kit

License

MIT © Vladimir Starkov