← All procedures

node.run

Run a Node.js script and wait for completion

CLI
Package
@procedures/node · README
Path
["node","run"]
CLI
mark node run --script <string>
As data
{"$proc":["node","run"],"input":{}}

Use it

In TypeScript

import { Client, LocalTransport, PROCEDURE_REGISTRY } from "@procedures/client";
import "@procedures/node"; // registers its procedures

const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["node","run"], { script: "<script>" });
console.log(JSON.stringify(result));

From the command line

$ mark node run --script <string>

As data, in a program

{ "$proc": ["node", "run"], "input": { "script": "<script>" } }

Input

FieldTypeRequiredDefaultDescription
scriptstringyesScript path to run
argsstring[]noArguments to pass to the script
cwdstringnoWorking directory
envobjectnoEnvironment variables
timeoutnumbernoTimeout in milliseconds. At the timeout, the script and its child processes are killed.
maxOutputBytesintegernoThe most bytes kept of each output stream (default: 64 MiB). The procedure keeps the first bytes.

Output

FieldTypeRequiredDefaultDescription
exitCodenumberyesThe exit code of the script
stdoutstringyesThe standard output
stderrstringyesThe standard error
truncatedbooleannoTrue when an output stream was longer than maxOutputBytes
JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "script": {
        "type": "string",
        "description": "Script path to run"
      },
      "args": {
        "description": "Arguments to pass to the script",
        "type": "array",
        "items": {
          "type": "string"
        }
      },
      "cwd": {
        "description": "Working directory",
        "type": "string"
      },
      "env": {
        "description": "Environment variables",
        "type": "object",
        "propertyNames": {
          "type": "string"
        },
        "additionalProperties": {
          "type": "string"
        }
      },
      "timeout": {
        "description": "Timeout in milliseconds. At the timeout, the script and its child processes are killed.",
        "type": "number"
      },
      "maxOutputBytes": {
        "description": "The most bytes kept of each output stream (default: 64 MiB). The procedure keeps the first bytes.",
        "type": "integer",
        "exclusiveMinimum": 0,
        "maximum": 9007199254740991
      }
    },
    "required": [
      "script"
    ]
  },
  "output": {
    "type": "object",
    "properties": {
      "exitCode": {
        "type": "number",
        "description": "The exit code of the script"
      },
      "stdout": {
        "type": "string",
        "description": "The standard output"
      },
      "stderr": {
        "type": "string",
        "description": "The standard error"
      },
      "truncated": {
        "description": "True when an output stream was longer than maxOutputBytes",
        "type": "boolean"
      }
    },
    "required": [
      "exitCode",
      "stdout",
      "stderr"
    ],
    "additionalProperties": {}
  }
}