From 4123987c3c0af8b732fb381420d5e0035a6014d3 Mon Sep 17 00:00:00 2001 From: Josselin Date: Thu, 15 Nov 2018 12:01:31 +0100 Subject: [PATCH] Run truffle compile automatically --- slither/__main__.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/slither/__main__.py b/slither/__main__.py index 8ebd16e9c..e4333cc3c 100644 --- a/slither/__main__.py +++ b/slither/__main__.py @@ -7,6 +7,7 @@ import logging import os import sys import traceback +import subprocess from pkg_resources import iter_entry_points, require @@ -58,6 +59,18 @@ def _process(slither, detector_classes, printer_classes): return results, analyzed_contracts_count def process_truffle(dirname, args, detector_classes, printer_classes): + cmd = ['truffle','compile'] + logger.info('truffle compile running...') + process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + + stdout, stderr = process.communicate() + stdout, stderr = stdout.decode(), stderr.decode() # convert bytestrings to unicode strings + + logger.info(stdout) + + if stderr: + logger.error(stderr) + if not os.path.isdir(os.path.join(dirname, 'build'))\ or not os.path.isdir(os.path.join(dirname, 'build', 'contracts')): logger.info(red('No truffle build directory found, did you run `truffle compile`?'))