{"action":"created","issue":{"url":"https://api.github.com/repos/srs/gradle-node-plugin/issues/48","labels_url":"https://api.github.com/repos/srs/gradle-node-plugin/issues/48/labels{/name}","comments_url":"https://api.github.com/repos/srs/gradle-node-plugin/issues/48/comments","events_url":"https://api.github.com/repos/srs/gradle-node-plugin/issues/48/events","html_url":"https://github.com/srs/gradle-node-plugin/issues/48","id":58576435,"number":48,"title":"Node tasks should honour workDir property","user":{"login":"Antillean","id":2972287,"avatar_url":"https://avatars.githubusercontent.com/u/2972287?v=3","gravatar_id":"","url":"https://api.github.com/users/Antillean","html_url":"https://github.com/Antillean","followers_url":"https://api.github.com/users/Antillean/followers","following_url":"https://api.github.com/users/Antillean/following{/other_user}","gists_url":"https://api.github.com/users/Antillean/gists{/gist_id}","starred_url":"https://api.github.com/users/Antillean/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Antillean/subscriptions","organizations_url":"https://api.github.com/users/Antillean/orgs","repos_url":"https://api.github.com/users/Antillean/repos","events_url":"https://api.github.com/users/Antillean/events{/privacy}","received_events_url":"https://api.github.com/users/Antillean/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-02-23T11:54:43Z","updated_at":"2015-03-07T18:00:39Z","closed_at":null,"body":"Setting the workDir property on the node object doesn't also set the workingDir property on the default node tasks (such as npmInstall). This results in npm looking for my package.json in the directory of the project I'm running from rather than in my working directory. I've had to work around it by making a task npmInstallCustom as follows:\r\n\r\n```javascript\r\ntask npmInstallCustom(type: NpmTask) {\r\n    execOverrides {\r\n        it.workingDir = nodeBuildDir\r\n    }\r\n\r\n    setArgs( ['install'] )\r\n\r\n    inputs.file { file(\"$nodeBuildDir/package.json\") }\r\n    outputs.dir { file(\"$nodeBuildDir/node_modules\") }\r\n}\r\n```\r\n\r\nAdditionally the inputs file defined for the NpmInstallTask is a (possibly non-exstient) package.json in the project directory. Line 18 of NpmInstallTask.groovy reads:\r\n\r\n```java\r\ngetInputs().file( new File( this.project.getProjectDir(), 'package.json' ) )\r\n```\r\n\r\nIt'd be good if the NpmInstallTask (and perhaps all NodeTasks or all NpmTasks?) defaulted its/their exec working directory and inputs directory to the working directory set on the node object. \r\n\r\n(I've raised [a similar issue with the grunt plugin](https://github.com/srs/gradle-grunt-plugin/issues/22).)"},"comment":{"url":"https://api.github.com/repos/srs/gradle-node-plugin/issues/comments/77701138","html_url":"https://github.com/srs/gradle-node-plugin/issues/48#issuecomment-77701138","issue_url":"https://api.github.com/repos/srs/gradle-node-plugin/issues/48","id":77701138,"user":{"login":"nmalaguti","id":33187,"avatar_url":"https://avatars.githubusercontent.com/u/33187?v=3","gravatar_id":"","url":"https://api.github.com/users/nmalaguti","html_url":"https://github.com/nmalaguti","followers_url":"https://api.github.com/users/nmalaguti/followers","following_url":"https://api.github.com/users/nmalaguti/following{/other_user}","gists_url":"https://api.github.com/users/nmalaguti/gists{/gist_id}","starred_url":"https://api.github.com/users/nmalaguti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nmalaguti/subscriptions","organizations_url":"https://api.github.com/users/nmalaguti/orgs","repos_url":"https://api.github.com/users/nmalaguti/repos","events_url":"https://api.github.com/users/nmalaguti/events{/privacy}","received_events_url":"https://api.github.com/users/nmalaguti/received_events","type":"User","site_admin":false},"created_at":"2015-03-07T18:00:39Z","updated_at":"2015-03-07T18:00:39Z","body":"I've submitted a PR that should address this https://github.com/srs/gradle-node-plugin/pull/52"}}