Re:Show HN: Auto install npm dependencies as you code
by siddharthkp on Monday August 08, 2016 @02:17PM
(#12249764)
Good point, any ideas on handling this better?
Opened an issue here: https://github.com/siddharthkp/auto-install/issues/2
Re:Show HN: Auto install npm dependencies as you code
by qwertyuiop924 on Monday August 08, 2016 @03:08PM
(#12250129)
The idea is inherently flawed. depandancy installation should be done as needed by people who are conciously aware of what they are doing. A better solution would be integrating NPM into your editor, so that package installation is trivial, but still explicit. M-x install-from-npm-region, anyone?
(defun install-from-npm-region (start end)
(interactive "r")
(call-process
(concat "npm install "
(shell-quote-argument
(filter-buffer-substring start end)))
nil
(get-buffer-create "*NPM Output*")))
That function MIGHT install random things through NPM if your mark is unset, but it is, at least, explicit. And the random thing in question is your last region, so it's far more likely that NPM will just throw its hands and shout "what the hell?" Than actually install anthing...Also note that that code hasn't been tested. I wouldn't copy this into my .emacs just yet, if I were you. Run it by somebody who actually knows elisp, first.
Re:Show HN: Auto install npm dependencies as you code
by cortesoft on Monday August 08, 2016 @02:22PM
(#12249802)
I don't really know if there is a way to fix this issue... unless you had some sort of whitelist of acceptable packages, and a prompt if you try to install a non-whitelisted package.
One other possibility is to have a delay, so that it waits an amount of time before installing, to give a chance to catch and fix the typo.
Re:Show HN: Auto install npm dependencies as you code
by siddharthkp on Monday August 08, 2016 @04:35PM
(#12250678)
Added a --secure flag which will install popular modules only (>10k downloads last month)
Re:Show HN: Auto install npm dependencies as you code
by cortesoft on Monday August 08, 2016 @04:38PM
(#12250694)
Good idea!
Re:Show HN: Auto install npm dependencies as you code
by binarymax on Monday August 08, 2016 @02:24PM
(#12249818)
If I understand correctly, this doesn't happen while you type, it happens after you save the file. Not much difference in care needed between saving a file or hitting enter IMO, if you are aware of the consequences. Also, its not like you don't know the thing is running - you'll subconsciously double check you typed the repo correctly before you save, knowing it will invoke an install.
Re:Show HN: Auto install npm dependencies as you code
by pavel_lishin on Monday August 08, 2016 @02:38PM
(#12249916)
Unless your IDE, like many, auto-saves files.
Re:Show HN: Auto install npm dependencies as you code
by qwertyuiop924 on Monday August 08, 2016 @03:12PM
(#12250151)
Even Emacs'll do that.
With this, you have to be careful the WHOLE time you are typing. You normally don't worry about hitting return in your editor causing RCE.