Home Reference Source
import Script from 'scripteasy/src/script.js'
public class | source

Script

A class that represents the commands, control flow, and context of a singe script.

Static Method Summary

Static Public Methods
public static

exec(command: string, args: Array<string>, cwd: string, env: object): Error

Executes a single command with the given args, cwd, and env

Constructor Summary

Public Constructor
public

Creates a new Script instance.

Member Summary

Public Members
public
public
public
public
public
public

Method Summary

Public Methods
public

run(args: Array<string>): Error

Runs the script.

Static Public Methods

public static exec(command: string, args: Array<string>, cwd: string, env: object): Error source

Executes a single command with the given args, cwd, and env

Params:

NameTypeAttributeDescription
command string

The command to execute.

args Array<string>
  • optional

The args to pass into the command.

cwd string
  • optional
  • default: process.cwd()

The current working directory.

env object
  • optional
  • default: process.env

The environment variables to execute the command with.

Return:

Error

If an error occurs, the error is returned.

Public Constructors

public constructor(st: Scripteasy, opts: object) source

Creates a new Script instance.

Params:

NameTypeAttributeDescription
st Scripteasy

The parent Scripteasy instance.

opts object
  • optional
  • default: {}

The script configuration options.

opts.try Array<string> | string
  • optional
  • default: []

The main script commands.

opts.catch Array<string> | string
  • optional
  • default: []

The catch block commands that will run if the try block fails.

opts.finally Array<string> | string
  • optional
  • default: []

The finally block commands that will always run after the try/ctch blocks.

opts.cwd string
  • optional
  • default: process.cwd()

The current working dir the script should run in.

opts.env object
  • optional
  • default: {}

The environment variables to pass in. These will not override environment variables in the current context.

Public Members

public catch: Array<string> source

public cwd: string source

public env: object source

public finally: Array<string> source

public st: Scripteasy source

public try: Array<string> source

Public Methods

public run(args: Array<string>): Error source

Runs the script.

Params:

NameTypeAttributeDescription
args Array<string>
  • optional

The args to pass into the command.

Return:

Error

If an error occurs, the error is returned.