Global Variables

Unless you are running in no-frills mode, all Spice scripts and modules can access the following methods and objects:

Module objects

Spice objects

The following Espresso classes are also available globally; see the Espresso API for usage information:

  • CETextRecipe
  • CETextSnippet
  • MRRangeSet
  • SXSelectorGroup

require function

require(module, [filePaths, loadGlobally, forceReload])


The module identifier you wish to load; this should be the name of your script file without the .js extension
filePaths (optional)
A string (if a single path) or array of paths you wish to search within the Support folder. For instance, if you wanted to load a module from Support/Scripts instead of Support/Library for some reason you could run require('my_script', 'Scripts').
loadGlobally (optional)
A boolean; true if you wish to execute the script globally instead of as a module. You should rarely if ever need this.
forceReload (optional)
A boolean; true if you wish to reload the script from the file even if it has already been loaded.

Returns exported module object, or a bool if loading globally, [filePaths])

Shortcut for including modules globally and accepts the first two arguments of require(); you will almost never need to use this function unless you require mootools-server:'mootools-server').

Returns bool; was the module successfully loaded or not.

Will return true if the module was previously loaded, even though it was not executed again.

require.force(module, [filePaths, loadGlobally])

Shorcut for force reloading a module. First three parameters are identical to require().

Returns module exports object or bool if loading globally.

system object


Logs the passed string or object to the console; view logged items in (in /Applications/Utilities/)


Identical to system.print().

You may optionally call system.log.fatal(message), system.log.error(message), system.log.warn(message),, or system.log.debug(message) but at this time they behave identically to system.print() as well., shell, envObject)

Executes a shell command (or string of commands).


A string; the command, or sequence of commands, that you wish to have executed.
A string; the name of the shell you wish to use. Available options are ‘bash’, ‘csh’, ‘ksh’, ‘sh’, ‘tcsh’, or ‘zsh’. Optional; defaults to ‘bash’.
An object; an object of key:value pairs that you wish to be populated in your shell’s environment for use by the command. Optional.

Returns string; the output of the command (if any).

system.modules object

This object contains all modules currently loaded, sorted by module identifier (what you pass to require()). Each module additionally has the following attributes:

Bool; was the module evaluated globally
String; the path to the script

Don’t mess around with the system.modules object unless you know what you’re doing. In normal usage, you should never need to access it at all.

context object

The context object is the textContext or fileContext passed to your script from Espresso; refer to the Espresso API for details on available methods. You should rarely if ever need to use this object if you are using Spice’s bundled utility modules.


The SpiceController object offers access to the Spice class’s API. For all available properties and methods, see the Spice header file. Under normal usage, you should never need to access this object.

Clicky Web Analytics