Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
gavingolden opened this issue Jun 13, 2019 · 8 comments
Open
Labels
workaround exists There is a workaround for this already

Comments

@gavingolden
Copy link

gavingolden commented Jun 13, 2019

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

> [email protected] 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:

> [email protected] 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! [email protected] 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?

@deepy
Copy link
Member

deepy commented Jun 13, 2019

I'll see if I can reproduce this when I get home, but the fact that you're getting console output means that you don't have to worry about the up-to-date, nodeSetup is probably the task that's up-to-date. You can use gradle --info or --profile to see what's really being done.

This however seems kinda strange, could you double-check the exit code of npm run lint outside of gradle? (just run it and then see what echo $? says)

@gavingolden
Copy link
Author

Thanks for the quick feedback. The exist code of npm run lint is 2.

And I confirmed that the lint task isn't being skipped by gradle

> ./gradlew lint --info
> Task :gateway:lint
Task ':gateway:lint' is not up-to-date because:
  Task has not declared any outputs despite executing actions.

@deepy
Copy link
Member

deepy commented Jun 17, 2019

I've reproduced this in https://github.com/deepy/testcase but I can't see why the project.exec() fails in the plugin, but not in the specific tasks I set up. Will continue troubleshooting later on.

@deepy
Copy link
Member

deepy commented Jun 19, 2019

When changing the testcase like this the problem goes away, further troubleshooting necessary

node {
    version = '10.15.3'
    npmVersion = '6.9.0'
    download = true
}

@deepy
Copy link
Member

deepy commented Jun 19, 2019

@gavingolden what does npm --version give you?
On 6.4.1 the lint task fails for me, on 6.9.0 and 6.5.0 it works
Hmm, it works for me if I specify a npmVersion, even if I do npmVersion = '6.4.1' which is the version I get if I do not specify one...

@deepy deepy changed the title NPM task is not causing an expected error NPM task is not causing an expected error if npmVersion is not set Jun 19, 2019
@deepy deepy added the workaround exists There is a workaround for this already label Jun 19, 2019
@gavingolden
Copy link
Author

gavingolden commented Jun 20, 2019

I have a global npm version of 6.9.0, which exhibited the broken behavior when npmVersion is not set. However...as you said: after setting that very same version explicitly in build.gradle it worked

@deepy
Copy link
Member

deepy commented Jun 25, 2019

We still want to solve the underlying issue here, even if a workaround exists :-)

@deepy deepy reopened this Jun 25, 2019
@gavingolden
Copy link
Author

ha oops, I referenced this issue in a private PR and merging it caused it to close automatically

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
workaround exists There is a workaround for this already
Projects
None yet
Development

No branches or pull requests

2 participants