Skip to content

Commit

Permalink
Moved parent-require.js into ./lib folder. Added original author info…
Browse files Browse the repository at this point in the history
…rmation on top of the parent-require.js file. Removed the support folder from ./lib . Ran standard --fix. Tried replacing let parent = module.parent with parent = Object.values(require.cache).filter((m) => m.children.includes(module)) but got error. Researching on a work around for now.
  • Loading branch information
RailonA committed May 3, 2023
1 parent 1697ea7 commit 096acb4
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions lib/parent-require.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
/**
* Author: Jared Hanson
* github repo: https://github.com/jaredhanson/node-parent-require
* license type: MIT License
* license type: MIT License
* license link: https://opensource.org/license/mit/
**/

module.exports = function (id) {

var parent = module.parent;
let parent = module.parent

for (; parent; parent = parent.parent) {
try {
return parent.require(id)
} catch (ex) {}
}
throw new Error("Cannot find module '" + id + "' from parent")


}

0 comments on commit 096acb4

Please sign in to comment.