Skip to content

Instantly share code, notes, and snippets.

@GNSPS
Last active December 7, 2017 01:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GNSPS/4dd479aaf2d4a06ccca6ae89745e0bab to your computer and use it in GitHub Desktop.
Save GNSPS/4dd479aaf2d4a06ccca6ae89745e0bab to your computer and use it in GitHub Desktop.
Bash script meant to easily change the version of `solc` that comes packaged with Truffle when you install it globally
#!/bin/bash
# ------------------------------------------------------------------
# [GNSPS] Truffle's solc version changer
#
# Bash script to change the version of the solc the
# Truffle module comes packaged with.
#
#
# Installation: save this file as
#
# 'solc-changer'
#
# then run
#
# 'chmod u+x solc-changer'
#
# and copy it to somewhere in your $PATH
# which in mac OS is simply:
#
# 'mv solc-changer /usr/local/bin/solc-changer'
#
# and finally run it with the version argument like:
#
# $ solc-changer 0.4.11
#
# ------------------------------------------------------------------
VERSION=0.0.1
SUBJECT=truffle-solc-changer
USAGE="v$VERSION\n\nUsage: $0 <desired_solc_version>"
CURR_PWD=$(pwd)
# --- Options processing -------------------------------------------
if [ $# == 0 ] ; then
echo -e $USAGE
exit 1;
fi
param1=$1
# --- Locks -------------------------------------------------------
LOCK_FILE=/tmp/$SUBJECT.lock
if [ -f "$LOCK_FILE" ]; then
echo "Script is already running"
exit
fi
trap "rm -f $LOCK_FILE" EXIT
touch $LOCK_FILE
# --- Body --------------------------------------------------------
cd $(npm config get prefix)/lib/node_modules/truffle/
npm install solc@$param1 --save
cd "$CURR_PWD"
# -----------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment