/run-in-atom

Run CoffeeScript or JavaScript in Atom.

Primary LanguageCoffeeScriptMIT LicenseMIT

Run in Atom package Build Status

Run in Atom is an Atom package that allows code to be executed in the context of Atom itself. This means code can examine and manipulate Atom's state while it's running.

For example, running the following CoffeeScript with Run in Atom will log the contents of the current document to the console.

editor = atom.workspace.getActiveTextEditor()
editor.getText()

Contextual Menu

Example of calling asynchronous CoffeeScript with "Run In Atom" that triggers a visible UI change:

pane = atom.workspace.getActivePane()
editor = atom.workspace.getActiveTextEditor()
pane.splitDown(items: [atom.workspace.buildTextEditor()])

Command Palette

Documentation

Code can be run in the following ways. In all cases it runs the selection if it exists, otherwise the whole document. The code's result is logged to the console.

  • alt-cmd-r keyboard shortcut
  • Choosing "Run In Atom" from the command palette
  • Choosing "Run in Atom" from the contextual menu

This package is based on code from probablycorey's coffee-eval, with the following differentiating features:

  • Both CoffeeScript and JavaScript are supported.
  • Coffee Eval's output window has been removed.
  • There's a configuration option to automatically open the developer tools when code is run.
  • Code can by run from the contextual menu.
  • In GitHub Flavored Markdown, code can be run in fenced code blocks.