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

How to set node command line option #141

Closed
BroHammie opened this issue Sep 14, 2016 · 3 comments
Closed

How to set node command line option #141

BroHammie opened this issue Sep 14, 2016 · 3 comments
Milestone

Comments

@BroHammie
Copy link

I need to set the "--max-old-space-size" command line option for node when running a node task. I haven't found anything to set options for node only to set arguments for the node task being ran. Also, I don't think that "--max-old-space-size" is a node environment variable.

@srs srs added node and removed node labels Dec 4, 2016
@whboyd
Copy link
Contributor

whboyd commented Dec 9, 2016

I second this. The plugin places all args after the script, but according to the documentation the node cl requires 'options' such as --max-old-space-size (as opposed to 'arguments') to go before the script. Thus, with NodeTask it is impossible to use these options.

I did find a workaround, though, for anyone who might need it in the meantime:

import com.moowork.gradle.node.NodeExtension
/* This task configures the nodeRun task, setting its command line before it runs.
 * This is done via a task because the location of the node executable obtained by the
 * gradle-node-plugin is not available until the execution phase.
 */
task configNodeRun {
    dependsOn nodeSetup
    doLast {
        nodeRun.commandLine project.extensions.getByType(NodeExtension).variant.nodeExec, "--max-old-space-size=123", "main.js"
    }
}

task nodeRun (type: Exec){
    dependsOn configNodeRun
}

@srs
Copy link
Owner

srs commented Jan 13, 2017

Merged into master. Will be released in 1.1.0.

@srs srs closed this as completed Jan 13, 2017
@shorn
Copy link

shorn commented Apr 4, 2017

@srs Is there an equivalent of this for NpmTask instead of NodeTask? I've been banging my head against this for a while, but I can't seem to do this for an NPM task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants