1

Is there a way to automatically run a script (such as copy files from a to b) when the truffle migrate command finishes?

I want to copy the json files from the build/contracts folder into the a folder where my webapp code is.

Currently I use the "truffle develop" command console, soit would be cool, if I could just type "migrate" to for a deployment script to kick in and copy the files.

  • Why don't you write a script which calls truffle migrate and then copies those json files? – goodvibration May 8 '18 at 11:35
  • i don't think that is possible via truffle means of course, but you can write a JS script and run it with node or just in any kind of language you want. – Kaki Master Of Time May 8 '18 at 13:34
  • I can't run truffle migrate because it won't work on my office workstation. I can run the migrate command from inside the Truffle development console. – simbro May 8 '18 at 14:23
1

Truffle scripts are executed in stages. So you can create an additional state that is executed last (migrations/9_copy_artifacts.js). That will run after all previous stages have completed, so you will be sure the contract's artifacts will be in the build directory.

  • Thanks Ismael, actually that did the trick - worked perfectly - thank you! – simbro May 14 '18 at 15:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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