npm

Check out our latest tech talk, "JavaScript Supply Chain Security" presented by VP of Security, Adam Baldwin.Watch it here »

runtime-required

1.0.2 • Public • Published

runtime-required

travis score-codeclimate npm-downloads npm-version dm-david

Haven't you ever always needed to know what files are being required by your app? Okay, maybe not always, but once? No? Just me? Fine, move along then. But in case you need it, here's how it all works:

Install

It's in npm, of course:

npm install runtime-required

Usage

require('runtime-required')EventEmitter

Yup, you just include it in your project and it exposes an event emitter. There is only a single file event, and it has the following properties:

  • type {string}: one of
    • builtin (node's default modules)
    • module (ones that appear inside the node_modules directory)
    • file (from your own project... or I guess elsewhere on the filesystem)
  • id {string}: the identifier for this module. For module and file types, it will be a fully-resolved file path. For builtin types, it will be the name of the module.

Example

const required = require('runtime-required');
 
required.on('file', data => {
  console.log(`${data.type} module was required at "${data.id}"`);
});

install

npm i runtime-required

Downloadsweekly downloads

118

version

1.0.2

license

ISC

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability