Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
283 views
in Technique[技术] by (71.8m points)

node.js - When calling the webpack CLI, is there a way to know if the build has been successful or failed?

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?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...