• Packages
  • Themes
  • Documentation
  • Blog
  • Discussions
Sign in

eval-and-replace

Execute CoffeeScript, JavaScript or Shell code from the Atom editor and replace the code with the result
  • #eval
  • #replace
MoritzKn
1.2.0 400
2
  • Repo
  • Bugs
  • Versions
  • License
Flag as spam or malicious

eval-and-replace

Build Status

Execute CoffeeScript, JavaScript or Shell code from the Atom editor and replace the code with the result.

calc

calc

calc

calc

Install

apm install eval-and-replace

Commands

Commands Description Default keybinding
eval-and-replace:coffee Executes selected CoffeeScript code ctrl-shift-e ctrl-shift-c or ctrl-k ctrl-e
eval-and-replace:js Executes selected JavaScript code ctrl-shift-e ctrl-shift-j
eval-and-replace:shell Executes selected Shell code ctrl-shift-e ctrl-shift-s

Be careful with eval-and-replace:shell; nobody will prevent you from executing rm -rf /!

Shell environment variables

When executing shell code with eval-and-replace:shell you have access to these variables:

  • FILE_PATH: path to of the currently opened file
  • FILE_NAME: name of the currently opened file
  • PROJECT: path to the Atom project

CoffeeScript / JS Context

CoffeeScript / JS code is executed in its own context, this means you can only use ECMAScript functions (i.e. norequire). But the same context is used for all selections, so you can reuse variables. Additionally you have access to these functions and variables:

  • i, j, n, x, y, z: initialized with 0
  • filePath: path of the opened file
  • fileName: name of the opened file
  • project: path of the current Atom project
  • PI: alias for Math.PI
  • E: alias for Math.E
  • random(): alias for Math.random()
  • pow(): alias for Math.pow()
  • sqrt(): alias for Math.sqrt()
  • abs(): alias for Math.abs()
  • sin(): alias for Math.sin()
  • cos(): alias for Math.cos()
  • tan(): alias for Math.tan()
  • floor(): alias for Math.floor()
  • ceil(): alias for Math.ceil()
  • round(): alias for Math.round()

License

This project is licensed under the terms of the MIT license. A copy of the license can be found in the root directory of the project in the file LICENSE.md.

I think this package is bad news.

Good catch. Let us know what about this package looks wrong to you, and we'll investigate right away.

  • Terms of Use
  • Privacy
  • Code of Conduct
  • Releases
  • FAQ
  • Contact
with by