Skip to content

Commit

Permalink
Look for Truffle local version in package.json (close #154)
Browse files Browse the repository at this point in the history
  • Loading branch information
montyly committed Feb 4, 2019
1 parent 7ef4e05 commit 4b55be7
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions slither/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,17 @@ def _process(slither, detector_classes, printer_classes):
return results, analyzed_contracts_count

def process_truffle(dirname, args, detector_classes, printer_classes):
cmd = ['npx',args.truffle_version,'compile'] if args.truffle_version else ['truffle','compile']
logger.info('truffle compile running...')
if args.truffle_version:
cmd = ['npx',args.truffle_version,'compile']
elif os.path.isfile('package.json'):
cmd = ['truffle', 'compile']
with open('package.json') as f:
package = json.load(f)
if 'devDependencies' in package:
if 'truffle' in package['devDependencies']:
truffle_version = 'truffle@{}'.format(package['devDependencies']['truffle'])
cmd = ['npx', truffle_version,'compile']
logger.info("'{}' running (use --truffle-version [email protected] to use specific version)".format(' '.join(cmd)))
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

stdout, stderr = process.communicate()
Expand Down

0 comments on commit 4b55be7

Please sign in to comment.