Skip to content

Instantly share code, notes, and snippets.

@jmgunn87
Created February 19, 2014 01:06
Show Gist options
  • Save jmgunn87/9084171 to your computer and use it in GitHub Desktop.
Save jmgunn87/9084171 to your computer and use it in GitHub Desktop.
fun! Require(...)
if !system("npm install " . join(a:000, " ") . " --save")
let result = []
for dep in a:000
call add(result, substitute("var x = require('x');\n", "x", dep, "g"))
endfor
put = join(result, '')
endif
endfunction
command! -nargs=* RQ call Require(<f-args>)
@jmgunn87
Copy link
Author

usage:
:RQ dep1 dep2 dep3

this will install and save any number of dependencies you specify using npm and the will write out a block of require statements for those dependencies. So it's like a super snippet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment