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

Arguments to the script #7

Closed
xduseko opened this issue Jan 14, 2015 · 7 comments
Closed

Arguments to the script #7

xduseko opened this issue Jan 14, 2015 · 7 comments

Comments

@xduseko
Copy link

xduseko commented Jan 14, 2015

There is no way to pass arguments to the script. Instead, arguments can be passed only to the node.js executable using option execArgv.

var server = require('gulp-develop-server');
server.listen({
path: './stub/server.js',
execArgv : ['--param']
});

Expected behaviour:

"C:\Program Files\nodejs\node.exe" ./stub/server.js --param

Actual behaviour:

"C:\Program Files\nodejs\node.exe" --param ./stub/server.js

@pskaarup
Copy link

execArgv is used to pass arguments to node. i.e. --debug.

Use env to pass options to your app.
This will put the options on process.env, which wile not ideal is usable in development.

@PinkaminaDianePie
Copy link

without arguments in cli this module useless for any console-like tools. in many scenarios cli args more preferable than process.env

@pskaarup
Copy link

You are right but, I think this tool was created to launch node web-servers like express. It seems people like to use NODE_ENV to set env flags.

@PinkaminaDianePie
Copy link

not everytime. for example my SERVER has some commands:

Usage: app [options] [command]

Commands:

listen                   inititalize app and listen port
install                  install app in new environment
module [options] <name>  create new module with given name by template
bump [options] <module>  create new controller for given module by template
migration <name>         create new migration template for module with given name
*                        help

Options:

-h, --help     output usage information
-V, --version  output the version number

So, i dont have separate tools for app, if i need to start server i write "node app.js listen". If i need to create migration or new module template i use server as a command line tool. it works fine with process managers like PM2, but i can't start server from this gulp module.

narirou added a commit that referenced this issue Mar 25, 2015
narirou added a commit that referenced this issue Mar 25, 2015
Fix test code
Update Readme
@narirou
Copy link
Owner

narirou commented Mar 25, 2015

Hello.
Thank you for reports.
I now understand the cause of this problem. (sorry...)
So we added options.args for the client argument.

server.listen({
    path: './stub/server.js',
    args: ['--cliant-args'],
    execArgv : ['--harmony']
});

will parse

node --harmony ./stub/server.js --cliant-args

If there is no problem I will merge this fix in the next version.

@PinkaminaDianePie
Copy link

yeah, its just what i need, thank you!

@narirou
Copy link
Owner

narirou commented Mar 25, 2015

If there is a problem, please reopen the issue.
Thanks.

@narirou narirou closed this as completed Mar 25, 2015
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