Created
May 14, 2018 06:27
-
-
Save dead-claudia/bd83293a7d90d9c67a0dd58c9008ed2a to your computer and use it in GitHub Desktop.
Helpful Node.js REPL function (use via `node -r ./path/to/node-repl-autoload.js`).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict" | |
global.autoloadExport = (invoke, deps = []) => { | |
const req = global.require, [file] = deps = deps.map(req.resolve) | |
return arg => { | |
const mod = req(file) | |
deps.forEach(dep => delete req.cache[dep]) | |
return invoke(mod, arg) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment