• Packages
  • Themes
  • Documentation
  • Blog
  • Discuss
Sign in

atom-scripts

This package allow you to bind javascript functions to commands and key bindings just by writing those in a file.
  • #script
  • #macro
  • #run
  • #command
GCSBOSS
5,995
1
  • Repo
  • Bugs
  • Versions
  • License
Flag as spam or malicious

Scripts in Atom

This package allow you to bind javascript functions to commands (Ctrl-Shift-P) and key bindings just by writing those in a file.

How To

In the root of a specific the desired project, create a file named scripts.js. In this file, you will code the functions related to the this very project root, thus not binding them to stranger files.

Scripts File

Each scripts file must be a node module exporting an array of objects with the following properties:

  • name: Contains a string command name in lower case, dash separated words format. Ex.: 'build'; This will be used to identify the script.
  • match: Contains a string with a regex pattern. Eg.: '^index\\.js$'; This will filter the files allowed to run the script.
  • hotkey: Contains a key combination string in the atom default pattern. Eg.: 'ctrl-f9'; This will be the registered key binding for the script.
  • script: Contains the actual script as a function. The function will receive a data argument whose members provide a few utilities:
    • file: A string containing the active file path.
    • project: A string containing the active project root path.
    • exec: The child_process function for executing shell commands.

So we end up with the following file scripts.js.

module.exports = [
    {
        name: 'build',
        match: '^index\\.js$',
        hotkey: 'ctrl-f9',
        script: (data) => {
            // Your code here...
        }
    },
 
    {
        name: 'debug',
        match: '^.*\\.js$',
        hotkey: 'ctrl-f8',
        script: (data) => {
            // Your code here.
        }
    }
]

Contributing

For bug reporting, feature requesting and any issues, please refer to our active GitLab repo. Enjoy scripting!

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