Skip to main content

Variable: Mode

const Mode: Readonly<object>;

Modes are a way to define "profiles" for your Robo session. Each with its own config(s), envionment variables, and code.

import { Mode } from 'robo.js'

// Get the current mode
const mode = Mode.get()

// Check if the current mode is "dev"
if (Mode.is('dev')) {
// Do something
}

// Colorize text based on the current mode
console.log(Mode.color('Hello, world!'))

Everything is granular. You can even run multiple modes at the same time!

Learn more: Mode

Type declaration

color()

color: (text) => string = colorMode;

Returns the color function for the current mode. This is used to colorize logs based on the mode when multiple exist.

Parameters

ParameterType
textstring

Returns

string

get()

get: () => string;

The current mode this Robo instance is running in. This is set by the --mode CLI flag.

Defaults to production for robo start and development for robo dev.

Returns

string

is()

is: (mode) => boolean;

Checks if the current mode matches the provided mode.

Parameters

ParameterTypeDescription
modestringThe mode to check against.

Returns

boolean

true if the current mode matches the provided mode.