Run NodeApp in command-like way?

NodeApp's NLContext is able to interpret JS using evaluateScript. At the same time it supports argv and env:

What's working right now:

  • process: .argv, .env, .exit(), .nextTick()

How to run NodeApp in command-like way and pass command-line arguments? Relates to env. variables too.

After diving in source code i've found the answer: no argvs are passed, env are passed as NSProcessInfo.processInfo.environment (see NLContext.m):

JSValue *process = [JSValue valueWithObject:@{
        @"platform": @"darwin",
        @"argv":     @[],
        @"env":      NSProcessInfo.processInfo.environment,
        @"execPath": NSBundle.mainBundle.executablePath,
        @"_asyncFlags": @{},
        @"moduleLoadList": @[]
    } inContext:context];

To modify them one need to add setters and pass variables before NLContext.attachToContext invocation is done.

PS. -1 to karma to 2 'close' voters. Hope my question and answer help somebody