module: add path to the module object · nodejs/node@9b27d5e (original) (raw)
Navigation Menu
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Appearance settings
Commit 9b27d5e
authored and
committed
module: add path to the module object
This adds the `path` property to the module object. It contains the current directory as path. That is necessary to add an extra caching layer. It also makes sure the `id` uses a default in case it's not set. Otherwise the `path.dirname(id)` command could fail. PR-URL: #26970Refs: #25362Reviewed-By: Guy Bedford guybedford@gmail.com Reviewed-By: Matteo Collina matteo.collina@gmail.com Signed-off-by: Beth Griggs Bethany.Griggs@uk.ibm.com
File tree
1 file changed
lines changed
1 file changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -96,8 +96,9 @@ function updateChildren(parent, child, scan) { | ||
96 | 96 | children.push(child); |
97 | 97 | } |
98 | 98 | |
99 | -function Module(id, parent) { | |
99 | +function Module(id = '', parent) { | |
100 | 100 | this.id = id; |
101 | +this.path = path.dirname(id); | |
101 | 102 | this.exports = {}; |
102 | 103 | this.parent = parent; |
103 | 104 | updateChildren(parent, this, false); |