3

Say you have a contract and you want it to watch for changes and run truffle compile --reset. Is there a way to do this?

1

1 Answer 1

1

Yes, you can do it using an automation library like gulp. For example a very basic and easy gulpfile could be the following:

var gulp = require('gulp');
var exec = require('child_process').exec;

gulp.task('run-command', function (cb) {
  exec('truffle compile --reset', function (err, stdout, stderr) {
    console.error(stderr);
    console.log(stdout);

    cb(err);
  });
})

gulp.task('watch', function() {
    gulp.watch('contracts/**/*.sol', ['run-command']);
});


gulp.task('default', function() {
  gulp.start('watch');
});

you can enrich it as you wish. Just install gulp with npm install gulp then save the file as gulpfile.js and launch gulp with ./node_modules/.bin/gulp (or just gulp)

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.