generator-fountain-webapp icon indicating copy to clipboard operation
generator-fountain-webapp copied to clipboard

gulp build returning 0 when failing

Open Toub opened this issue 8 years ago • 3 comments

Description

If gulp build fails, the process should return a non-zero code to stop the build/deployment process.

With a fresh generated app with [email protected], just add the following line to index.js:

invalid-code();
gulp build

The process fails:

[...]
ERROR in ./src/index.js
[...]
4 problems (4 errors, 0 warnings)
[11:44:13] Finished 'webpack:dist' after 8.72 s
[11:44:13] Finished 'build' after 8.81 s

But it returns a 0 (SUCCESS) error code:

echo $?
0

A non-zero error is expected in case of failure.

Config

{
  "generator-fountain-angular1": {
    "version": "0.6.0",
    "props": {
      "framework": "angular1",
      "modules": "webpack",
      "js": "babel",
      "css": "scss",
      "resolved": "/usr/local/lib/node_modules/generator-fountain-webapp/node_modules/generator-fountain-angular1/generators/app/index.js",
      "namespace": "fountain-angular1",
      "argv": {
        "remain": [],
        "cooked": [],
        "original": []
      },
      "skip-cache": false,
      "skip-install": false,
      "sample": "techs",
      "router": "uirouter"
    }
  }
}

Environment

Reproduced in 2 environments:

Node.js v5.6.0
linux 4.1.0-1-amd64
 $ yo --version
1.8.4
$ npm version
3.6.0
Node.js v6.2.2
linux 4.1.0-1-amd64
$ yo --version
1.8.4
$ npm --version
3.9.5

Toub avatar Jul 24 '16 09:07 Toub

invalid-code(); ? Why ?

micaelmbagira avatar Jul 28 '16 07:07 micaelmbagira

invalid-code(); ? Why ?

It is just an example of code that breaks the build.

If the build is broken, gulp should return a non-zero error code, else automated tools such as jenkins or ansible won't know about the error and will continue the deployment, resulting to deploy a broken application.

Toub avatar Jul 28 '16 08:07 Toub

I have the same issue with generator 0.7.1 and typescript with webpack

This issue is documented in typescript-loader : https://github.com/TypeStrong/ts-loader#failing-the-build-on-typescript-compilation-error

To solve this, we just need to add the fail-plugin to webpack : https://www.npmjs.com/package/webpack-fail-plugin

JulienBourgain avatar Aug 30 '16 09:08 JulienBourgain