Skip to content

Instantly share code, notes, and snippets.

@dead-claudia
Created May 14, 2018 06:27
Show Gist options
  • Save dead-claudia/bd83293a7d90d9c67a0dd58c9008ed2a to your computer and use it in GitHub Desktop.
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`).
"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