0

I have a deploy.sh file that will call webpack like:

webpack --config webpack.prod.js

Does that call return something that I can use to know if the build has been successful or not? Because I'd like to know if my deploy.sh script should continue or not.

Any other solutions to this?

cbdeveloper
  • 27,898
  • 37
  • 155
  • 336
  • *Does that call return something[?]* It does return an exit status (accessible through `$?`), have you tried checking it? – oguz ismail Jan 12 '21 at 11:59
  • It does return a `string` with a bunch of info. I'll try to work with that. But you must be careful because this call with the error on the command itself does not return anything. For example: `webpack --config INEXISTENT_FILE.config.js`. But there is a string that returns after the build itself that I'll try to use to check for success or fail. Thanks. – cbdeveloper Jan 12 '21 at 14:35

1 Answers1

0

You can use the exit code from the webpack CLI script to detect this:

https://github.com/webpack/webpack-cli#exit-codes-and-their-meanings

build.sh

webpack --config webpack.prod.js

EXIT_CODE=$?

if [[ EXIT_CODE == "0" ]]; then
  echo "BUILD SUCCESSFUL"
  exit
else
  echo "ERROR ON BUILD SCRIPT"
  exit
fi
cbdeveloper
  • 27,898
  • 37
  • 155
  • 336