Builders
Builders are small JSON files that describe how to build files of a certain type. When a user hits the build
menu item in Cloud9 it will use the filename to determine which builder to choose and use that builder to build that file. Users can use the run menu to select a builder of choice to build the current file with. Optionally the user can choose to run builders automatically when saving a file.
Creating a New Builder
You'll want to include one or more builders in your package when you are adding support for a new runtime or pre-processor.
Create a new builder via the menu Run / Build System / New Build System
or copy the following template.
{
"cmd": ["ls", "$file", "$args"],
"env": {},
"selector": "source.ext"
}
The cmd
property takes an array of command line arguments and replaces any of the accepted variables to build a command that is executed through bash. The command is run with any environment variables set in env
.
The selector
property is a regular expression used by Cloud9 to identify the filenames that apply to that builder.
These are the supported variables.
Variable | Description |
---|---|
$file_path | The directory of the current file, e.g. /home/ubuntu. |
$file | The full path to the current file, e.g. /home/ubuntu/server.js. |
$args | Any arguments entered after the file name. |
$file_name | The name portion of the current file, e.g. server.js. |
$file_extension | The extension portion of the current file, e.g. js. |
$file_base_name | The name only portion of the current file, e.g. server. |
$packages | The full path to the Packages folder. |
$project | The full path to the current project file. |
$project_path | The directory of the current project file. |
$project_name | The name portion of the current project file. |
$project_extension | The extension portion of the current project file. |
$project_base_name | The name only portion of the current project file. |
$hostname | The hostname of the workspace. |
$hostname_path | The hostname of the workspace together with the relative path of the project file. |
$url | The full url to access the workspace. |
$port | The port assigned to the workspace. |
$ip | The ip address to run a process against in the workspace. |
The following declarations can be used to add defaults or regexp
replacements to the these variables:
${debug?--debug}
This will emit --debug if the debug option is set to true
${project_name:Default}
This will emit the name of the current project if there is one, otherwise Default.
${file/\.php/\.txt/}
This will emit the full path of the current file, replacing .php with .txt.
Please check out the reference guide for more information on each of the properties that are accepted for builders.
Updated less than a minute ago