Skip to content

Commit

Permalink
Merge pull request #19 from studioartlan/master
Browse files Browse the repository at this point in the history
allow parameters to be specified in script path
  • Loading branch information
getnamo authored Apr 29, 2020
2 parents 9514ae4 + ccf63a0 commit 08ee20e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Content/Scripts/scriptHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,16 @@ const startScript = (scriptName, socket, scriptPath)=>{
if(!scriptPath){
scriptPath = './';
}
let fullScriptPath = scriptPath + scriptName;

let child = childProcess.fork(scriptPath + scriptName, [], { silent: true });
// QUICKFIX: allow parameters to be specified in script path, separated from script path by |
let scriptNameAndParameters = scriptName.split('|');
let fullScriptPath = scriptPath + scriptNameAndParameters[0];
let parameters = [];

if (scriptNameAndParameters[1])
parameters = scriptNameAndParameters[1].match(/[^"]+|[^\s"]+/g);

let child = childProcess.fork(fullScriptPath, parameters, { silent: true });
ipc = new IPCEventEmitter(child);
let pid = child.pid;

Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ In your component properties set the name of the script you wish to run e.g. ```

![set script](https://i.imgur.com/xalQplZ.png)

### Command line arguments

Command line arguments are supported, just add them to the script path, separated by "|".
Arguments which contain spaces should be enclosed in double quotes. Example:

`myscript.js|--parameter=value "--parameter-with-spaces=value with spaces"`

Now let's look at a basic script

### Node Scripts
Expand Down

0 comments on commit 08ee20e

Please sign in to comment.