node-gradle / node-gradle/gradle-node-plugin

NPM task is not causing an expected error if npmVersion is not set

Open
#18 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

workaround exists
Dominant language
Groovy
Stars
677
Forks
120
PR merge metrics
No merged PRs in 30d

Description

With the following configuration, I noticed that the gradle npm task is not failing when it should. I tested this by running the npm run test task directly from the same directory and it returned the expected linting error (so there's an error yet the gradle task passes without any of the expected error output).

Command: ./gradlew lint
Ouput:

> Task :gateway:lint

> gateway@0.0.0 debug /my/user/project/modules/gateway
> npx lint


BUILD SUCCESSFUL in 0s
2 actionable tasks: 1 executed, 1 up-to-date

Command: npm run lint
Output:

> gateway@0.0.0 lint /my/user/project/modules/gateway
> npx tslint -p tsconfig.json -c tslint.json


ERROR: /my/user/project/modules/gateway/src/server/user-auth/service.ts:14:61 - Missing semicolon

npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! gateway@0.0.0 lint: `npx tslint -p tsconfig.json -c tslint.json`
npm ERR! Exit status 2

build.gradle

node {
    version = "10.15.0"
    download = true
}

task lint(type: NpmTask) {
    args = ['run', 'lint']
}

package.json

"scripts": {
    "lint": "npx tslint -p tsconfig.json -c tslint.json"
},

I've tried debugging this with a few scenarios:

  •    "scripts": {
         "lint": "exit 1"
      },
    
    • This failed as expected
  •    "scripts": {
         "lint": "echo $(pwd)"
      },
    
    • This prints the expected root directory of the module

I suspect it might have to do with the gradle output 1 up-to-date, which I believe is part of the incremental build system. If that's the problem how do you recommend getting past it?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the NpmTask configuration shown in build.gradle and the lint script in package.json, then inspect how the plugin handles npmVersion and Gradle's up-to-date checks. Reproduce both ./gradlew lint and npm run lint with the provided configuration. Done means the Gradle task reports the lint failure and propagates its nonzero exit status.

Written by the indexing model from the issue text.

Assessment

Tech stack
groovy, nodejs, typescript
Domain
build-system, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.