FountainJS / generator-fountain-webapp

Yeoman 'fountain' generator to start a webapp
http://fountainjs.io
MIT License
963 stars 67 forks source link

gulp build returning 0 when failing #90

Open Toub opened 8 years ago

Toub commented 8 years ago

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 generator-fountain-webapp@0.6.0, 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
micaelmbagira commented 8 years ago

invalid-code(); ? Why ?

Toub commented 8 years ago

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.

JulienBourgain commented 8 years ago

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