Skip to content

Instantly share code, notes, and snippets.

@GNSPS GNSPS/solc-changer
Last active Dec 7, 2017

Embed
What would you like to do?
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
You can’t perform that action at this time.