LinuxCommandLibrary

coffee

Prevent the system from sleeping

TLDR

Run a script

$ coffee [path/to/file.coffee]
copy

Compile to JavaScript and save to a file with the same name
$ coffee --compile [path/to/file.coffee]
copy

Compile to JavaScript and save to a given output file
$ coffee --compile [path/to/file.coffee] --output [path/to/file.js]
copy

Start a REPL (interactive shell)
$ coffee --interactive
copy

Watch script for changes and re-run script
$ coffee --watch [path/to/file.coffee]
copy

SYNOPSIS

coffee [options] path/to/script.coffee -- [args]

PARAMETERS

-b, --bare
    Compile without top-level function wrapper

-c, --compile
    Compile to JavaScript and save as .js files

-e, --eval
    Pass a string from command line as input

-h, --help
    Print this help message

-i, --interactive
    Run an interactive CoffeeScript REPL

-j, --join <path>
    Concatenate source CoffeeScript before compiling

-l, --lint
    Pipe compiled JS through JavaScript Lint

-m, --map
    Generate source map and save as .map files

-n, --nodes
    Print the parse tree

-o, --output <PATH>
    Set output path for compiled JavaScript

-p, --print
    Print compiled JavaScript to stdout

-s, --stdio
    Compile scripts over stdio

-t, --tokens
    Print tokens from lexer/rewriter

-v, --version
    Print version number

-w, --watch
    Watch files for changes and recompile

DESCRIPTION

The coffee command is the command-line interface for CoffeeScript, a programming language that transpires into clean, readable JavaScript. It allows developers to compile .coffee source files into .js equivalents, execute scripts directly in Node.js, or launch an interactive REPL for experimentation.

Originally designed to eliminate verbose JavaScript boilerplate while maintaining full compatibility, CoffeeScript introduces significant whitespace, concise syntax for functions, classes, and modules. The coffee tool supports watching files for changes, generating source maps for debugging, linting output, and more. It's widely used in Node.js projects for backend scripting or browser apps via bundlers.

Invocation typically involves specifying input files or using flags for specific behaviors like printing compiled output or joining multiple files. When no options are given, it runs the script directly. Requires Node.js and the coffee-script npm package.

CAVEATS

Not a core Linux utility; requires Node.js and npm install -g coffee-script. Deprecated in favor of modern transpilers like Babel.

INSTALLATION

Install globally with npm install -g coffee-script or locally in projects.

BASIC USAGE EXAMPLE

coffee -c myscript.coffee compiles to myscript.js.
coffee -i starts interactive REPL.

HISTORY

Created by Jeremy Ashkenas in 2009; first release December 13, 2009. Evolved to version 2.x in 2017 with better ES6+ support. Maintained sporadically; version 2.7.0 released in 2023.

SEE ALSO

node(1), npm(1)

Copied to clipboard