mirror of
				https://github.com/nvm-sh/nvm.git
				synced 2025-10-31 18:25:52 +08:00 
			
		
		
		
	A package.json install that works.
It's an ugly hack, but it works.
This commit is contained in:
		
							
								
								
									
										24
									
								
								install.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										24
									
								
								install.sh
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,24 @@ | ||||
| #!/bin/bash | ||||
|  | ||||
| dir=$npm_config_root/.npm/$npm_package_name/$npm_package_version/package | ||||
|  | ||||
| # add lines to the bashrc. | ||||
| has=$(cat ~/.bashrc | egrep "^# ADDED BY npm FOR NVM$" || true) | ||||
| if [ "x$has" != "x" ]; then | ||||
|   exit 0 | ||||
| fi | ||||
| cat <<NVM_CODE >>~/.bashrc | ||||
| # ADDED BY npm FOR NVM | ||||
| NVM_DIR=$dir | ||||
| . \$NVM_DIR/nvm.sh | ||||
| nvm use | ||||
| # END ADDED BY npm FOR NVM | ||||
| NVM_CODE | ||||
|  | ||||
| cat <<NVM_HOWTO | ||||
|  | ||||
|   To use nvm, source your .bashrc file like this: | ||||
|     . ~/.bashrc | ||||
|   or log out and back into your terminal. | ||||
|  | ||||
| NVM_HOWTO | ||||
| @@ -1,5 +1,6 @@ | ||||
| { "name" : "nvm" | ||||
| , "version" : "0.0.2" | ||||
| , "bin" : { "nvm" : "./nvm.sh" } | ||||
| , "author" : "Tim Caswell <tim@creationix.org>" | ||||
| , "scripts" : | ||||
|   { "install" : "./install.sh" , "uninstall" : "./uninstall.sh" } | ||||
| } | ||||
|   | ||||
							
								
								
									
										23
									
								
								uninstall.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										23
									
								
								uninstall.sh
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,23 @@ | ||||
| #!/bin/bash | ||||
|  | ||||
|  | ||||
| has=$(cat ~/.bashrc | egrep "^# ADDED BY npm FOR NVM$" || true) | ||||
| if [ "x$has" == "x" ]; then | ||||
|   echo "doesn't have it, exiting" | ||||
|   exit 0 | ||||
| fi | ||||
| tmp=~/.bashrc.tmp | ||||
| cat ~/.bashrc | { | ||||
|   incode=0 | ||||
|   while read line; do | ||||
|     if [ "$line" == "# ADDED BY npm FOR NVM" ]; then | ||||
|       incode=1 | ||||
|     elif [ "$line" == "# END ADDED BY npm FOR NVM" ] \ | ||||
|           && [ $incode -eq 1 ]; then | ||||
|       incode=0 | ||||
|     elif [ $incode -eq 0 ]; then | ||||
|       echo "$line" >> $tmp | ||||
|     fi | ||||
|   done | ||||
| } | ||||
| mv $tmp ~/.bashrc | ||||
		Reference in New Issue
	
	Block a user