Search code examples
buildgruntjsjs-beautifygrunt-jsbeautifier

How can we fail a build job if JSBeautifier in Grunt needs to format a file?


Usually certain Grunt tasks have the option to "fail on warning", making it possible to put it as a step in your build process.

I am looking at JSBeautifier but it seems like there is no option.

Any suggestions on how we can make our build fail, if a JavaScript file gets formatted by JSBeautifier a build step?


Solution

  • If mode is "VERIFY_ONLY", then task will fail if at least one file can be beautified. This is useful for pre-commit check.

    https://www.npmjs.com/package/grunt-jsbeautifier#options-mode-optional