scott113341 / npm-install-version

Installs node modules to versioned or custom directories.
MIT License
56 stars 11 forks source link

Odd shell boilerplate #5

Closed dead-claudia closed 8 years ago

dead-claudia commented 8 years ago

I noticed you're using shx, which might be helpful with npm-based build systems, but instead of using shx rm -rf, shx mkdir -p, shx mv, etc., you could use rimraf.sync, mkdirp.sync, fs.renameSync, etc. to avoid the extra exec overhead. And if you need the ability to copy across partitions, ShellJS already uses an easy workaround.

Oh, and just another suggestion, but take it or leave it: use spawnSync for the npm calls, so if someone uses niv 'package@1 package@2', npm should error out, but does weird things instead.

scott113341 commented 8 years ago

Thanks @isiahmeadows, you are completely right! Check out #6 if you have a chance; I think both issues have been addressed.

I went with regular ShellJS commands like shelljs.rm, shelljs.mkdir, etc. instead of the packages you mentioned just because I am more familiar with ShellJS. If there is a compelling reason to use those other modules I'm happy to switch.

I also replaced all usage of execSync with spawnSync, since in every case spawnSync was a better choice.