You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With meteor I dearly miss the simplicity of npm install {pkg} and npm uninstall {pkg}
My OCD brain was hating having to look up the latest version of packages and manually add them to my packages.json file, so I made a little CLI so I can ./cli install {pkg} and ./cli uninstall {pkg} but this is not the most elegant of solutions
Any thoughts on a possible better solution that can be worked into this package? My quick and dirty CLI tool below
#!/usr/bin/env coffee# USAGE:# ./cli install chalk# ./cli uninstall chalkexec=require('child_process').execfs=require'fs'argv=process.argvhandleError= (error) ->throw error if error
command= argv[2]
switch command
when'install'pkg= argv[3]
exec"npm show #{pkg} version", (error, output) ->handleError error
latestVersion=output.trim()
fs.readFile'packages.json', 'utf8', (error, contents) ->handleError error
json=JSON.parse contents
json[pkg] = latestVersion
newString=JSON.stringify json, null, 2newString+='\n'fs.writeFile'packages.json', newString, (error) ->handleError error
console.info"Latest #{pkg} added to ./packages.json"when'uninstall'pkg= argv[3]
fs.readFile'packages.json', 'utf8', (error, contents) ->handleError error
json=JSON.parse contents
if json[pkg]
delete json[pkg]
elseconsole.warn"Huh? #{pkg} is not in your packages.json"returnnewString=JSON.stringify json, null, 2newString+='\n'fs.writeFile'packages.json', newString, (error) ->handleError error
console.info"#{pkg} removed from packages.json"
The text was updated successfully, but these errors were encountered:
With meteor I dearly miss the simplicity of
npm install {pkg}
andnpm uninstall {pkg}
My OCD brain was hating having to look up the latest version of packages and manually add them to my packages.json file, so I made a little CLI so I can
./cli install {pkg}
and./cli uninstall {pkg}
but this is not the most elegant of solutionsAny thoughts on a possible better solution that can be worked into this package? My quick and dirty CLI tool below
The text was updated successfully, but these errors were encountered: