<commit_before># Sublime Gulp

A plugin to run your [Gulp](http://gulpjs.com/) tasks from within Sublime plus some handy [snippets](#snippets) too.

## Quickstart

1. Install Via [Package Control](https://packagecontrol.io) `Gulp`
2. Open your repo containing either a `gulpfile.js` file or directory
3. If you don't already have a `default` gulp task make one
4. Menu to Tools>Gulp>Run Default Task
5. Enjoy!

## Installation

### via PackageControl
If you have [PackageControl](http://wbond.net/sublime_packages/package_control) installed, you can use it to install the package.

Just type `cmd-shift-p`/`ctrl-shift-p` to bring up the command pallete and pick `Package Control: Install Package` from the dropdown, search and select the package there and you're all set.

### Manually

You can clone the repo in your `/Packages` (*Preferences -> Browse Packages...*) folder and start using/hacking it.
    
    cd ~/path/to/Packages
    git clone git://github.com/NicoSantangelo/sublime-gulp.git Gulp

### Troubleshooting

For older gulp versions, the plugin makes use of [node](http://nodejs.org/) which should already be installed if you are using Gulp. It creates a cache using node, so in some systems you might need to add your node_modules path to the NODE_PATH, for example (for Unix):

`export NODE_PATH=/usr/local/lib/node_modules`

Sublime Gulp might not work without `var gulp = require('gulp');` defined in each task file. [More info](https://github.com/NicoSantangelo/sublime-gulp/issues/12) (thanks [@smeijer](https://github.com/smeijer) for the help)

If you are having trouble running the plugin in **Mac OSX** it's possible that your path isn't being reported by your shell. In which case give the plugin [SublimeFixMacPath](https://github.com/int3h/SublimeFixMacPath) a try. It may resolve our issue.

If you still can't get it to run properly, first make sure your Gulp tasks run from a terminal (i.e. outside of sublime) and if so then submit an [issue](https://github.com/NicoSantangelo/sublime-gulp/issues).


### CoffeeScript Support

If you want to use a `gulpfile.coffee` you need to do two things:

1. Add `module.exports = gulp` to your `gulpfile.coffee` so node can use it
2. Create a gulpfile.js if it doesn't exist and add this to it:

```javascript
require('coffee-script/register');
var gulp = require('./gulpfile.coffee');
```

### Gulpfile.js

The Sublime Gulp plugin was made for those using the [Gulp Streaming Build - Task Runner System](https://github.com/gulpjs/gulp) within [Node.js](https://nodejs.org/) for their workflow.

Sublime Gulp now supports not only a basic gulpfile.js file in the root of your project but also recognizes your tasks within a directory set by the RequireDir module or within a gulpfile.js directory. So no matter how your gulp tasks are organized Sublime Gulp will find them.

## Usage

### Available Commands

Sublime Gulp supports the following commands accessible from `Tools -> Command Palette` by typing in "Gulp". They are also accesible from menus as indicated below the table. `Default.sublime-commands` also lists them.

|     Command       |  From Command Palette | From Menu                 |
|:-----------------:|:---------------------:|:------------------------:|
| [gulp](#running-a-gulp-task)                | Gulp or Gulp (silent)     | List Tasks to Run |  
| [gulp_arbitrary](#arbitrary-task)           | Gulp: Run arbitrary task  | Run Arbitrary Task |  
| [gulp_kill](#killing-tasks)                 | Gulp: Kill All Gulp Tasks | Gulp: Kill running tasks |
| [gulp_delete-cache](#deleting-the-cache)    | Gulp: Delete Cache        | Gulp: Delete Cache |
| [gulp_plugins](#listing-gulp-plugins)       | Gulp: List plugins        | List Gulp Plugins |
| [gulp_show_panel](#show-or-hide-the-panel)  | Gulp: Show panel          | Show Gulp Panel |
| [gulp_hide_panel](#show-or-hide-the-panel)  | Gulp: Hide panel          | Hide Gulp Panel |
| [gulp_exit](#quitting-sublime-killing-running-gulp-tasks)  | Gulp: Exit editor killing running tasks | Quit Killing All Gulp Tasks |

* The first five commands are available via `Tools -> Gulp` in the main menu and in `Gulp` in the sidebar context menu.
* The the 6th and 7th are available via `View -> Gulp` in the main menu.
* The last command is available via `File` at the bottom in the main menu.


### Running a Gulp Task
To run a task, first choose `Gulp` from the command pallete or `List Tasks to Run` from the menu, the package will search for your tasks in the open folder/project and create a cache (`.sublime-gulp.cache`) in the root. The first run will be slow as the cache builds but then the cache will speed up future access. You can use the [`gulp_delete_cache`](#deleting-the-cache) command to rebuild the cache if you are not seeing your newly added Gulp Tasks or some have gone missing.

The plugin will then display all the Gulp tasks in a list. Selecting one will run that task. To show the task's standard output the plugin uses a panel or a new tab (depends on your [settings](#settings)). After a first task has been run you can use the hide and show panel commands as desired. (see table above) 

If you want to run the normal `Gulp` command without standard output to the panel use instead `Gulp (silent)`. 

#### Arbitrary task

When running an arbitrary task you need to choose `Gulp: Run arbitrary task` from the command pallete or `Run arbitrary task` from the menu. The package will then prompt an input panel where you can write what you want to add as a sufix to `gulp`.

### Customized Task Access

Out of the box Sublime Gulp has a menu item `Run Default Task` under `Tools -> Gulp` that will run your `default` Gulp task. Most Gulp users have a default task defined (like running their development tasks).

If you want to run other of your tasks from a menu item or [keyboard shortcut](#shortcut-keys) you can customize both.  

For example to add a menu item in the tools menu for a `sass` task do this. In your sublime user directory add following json in the `Main.sublime-menu` file (create one if you don't have one).

```json
{<commit_msg>Finishing touches on the README<commit_after># Sublime Gulp

A plugin to run your [Gulp](http://gulpjs.com/) tasks from within Sublime plus some handy [snippets](#snippets) too.

## Quickstart

1. Install Via [Package Control](https://packagecontrol.io) `Gulp`
2. Open your repo containing either a `gulpfile.js` file or directory
3. If you don't already have a `default` gulp task make one
4. Menu to Tools>Gulp>Run Default Task
5. Enjoy!

## Installation

### via PackageControl
If you have [PackageControl](http://wbond.net/sublime_packages/package_control) installed, you can use it to install the package.

Just type `cmd-shift-p`/`ctrl-shift-p` to bring up the command pallete and pick `Package Control: Install Package` from the dropdown, search and select the package there and you're all set.

### Manually

You can clone the repo in your `/Packages` (*Preferences -> Browse Packages...*) folder and start using/hacking it.
    
    cd ~/path/to/Packages
    git clone git://github.com/NicoSantangelo/sublime-gulp.git Gulp

### Troubleshooting

For older gulp versions, the plugin makes use of [node](http://nodejs.org/) which should already be installed if you are using Gulp. It creates a cache using node, so in some systems you might need to add your node_modules path to the NODE_PATH, for example (for Unix):

`export NODE_PATH=/usr/local/lib/node_modules`

Sublime Gulp might not work without `var gulp = require('gulp');` defined in each task file. [More info](https://github.com/NicoSantangelo/sublime-gulp/issues/12) (thanks [@smeijer](https://github.com/smeijer) for the help)

If you are having trouble running the plugin in **Mac OSX** it's possible that your path isn't being reported by your shell. In which case give the plugin [SublimeFixMacPath](https://github.com/int3h/SublimeFixMacPath) a try. It may resolve our issue.

If you still can't get it to run properly, first make sure your Gulp tasks run from a terminal (i.e. outside of sublime) and if so then submit an [issue](https://github.com/NicoSantangelo/sublime-gulp/issues).


### CoffeeScript Support

If you want to use a `gulpfile.coffee` you need to do two things:

1. Add `module.exports = gulp` to your `gulpfile.coffee` so node can use it
2. Create a gulpfile.js if it doesn't exist and add this to it:

```javascript
require('coffee-script/register');
var gulp = require('./gulpfile.coffee');
```

### Gulpfile.js

The Sublime Gulp plugin was made for those using the [Gulp Streaming Build - Task Runner System](https://github.com/gulpjs/gulp) within [Node.js](https://nodejs.org/) for their workflow.

Sublime Gulp now supports not only a basic gulpfile.js file in the root of your project but also recognizes your tasks within a directory set by the RequireDir module or within a gulpfile.js directory. So no matter how your gulp tasks are organized Sublime Gulp will find them.

## Usage

### Available Commands

Sublime Gulp supports the following commands accessible from `Tools -> Command Palette` by typing in "Gulp". They are also accesible from menus as indicated below the table. `Default.sublime-commands` also lists them.

|     Command       |  From Command Palette | From Menu                 |
|:-----------------:|:---------------------:|:------------------------:|
| [gulp](#running-a-gulp-task)                | Gulp or Gulp (silent)     | List Tasks to Run |  
| [gulp_arbitrary](#arbitrary-task)           | Gulp: Run arbitrary task  | Run Arbitrary Task |  
| [gulp_kill](#killing-tasks)                 | Gulp: Kill All Gulp Tasks | Kill running tasks |
| [gulp_delete-cache](#deleting-the-cache)    | Gulp: Delete Cache        | Delete Cache |
| [gulp_plugins](#listing-gulp-plugins)       | Gulp: List plugins        | List Gulp Plugins |
| [gulp_show_panel](#show-or-hide-the-panel)  | Gulp: Show panel          | Show Gulp Panel |
| [gulp_hide_panel](#show-or-hide-the-panel)  | Gulp: Hide panel          | Hide Gulp Panel |
| [gulp_exit](#quitting-sublime-killing-running-gulp-tasks)  | Gulp: Exit editor killing running tasks | Quit Killing All Gulp Tasks |

* The first five commands are available via `Tools -> Gulp` in the main menu and in `Gulp` in the sidebar context menu.
* The the 6th and 7th are available via `View -> Gulp` in the main menu.
* The last command is available via `File` at the bottom in the main menu.


### Running a Gulp Task
To run a task, first choose `Gulp` from the command pallete or `List Tasks to Run` from the menu, the package will search for your tasks in the open folder/project and create a cache (`.sublime-gulp.cache`) in the root. The first run will be slow as the cache builds but then the cache will speed up future access. You can use the [`gulp_delete_cache`](#deleting-the-cache) command to rebuild the cache if you are not seeing your newly added Gulp Tasks or some have gone missing.

The plugin will then display all the Gulp tasks in a list. Selecting one will run that task. To show the task's standard output the plugin uses a panel or a new tab (depends on your [settings](#settings)). After a first task has been run you can use the hide and show panel commands as desired. (see table above) 

If you want to run the normal `Gulp` command without standard output to the panel use instead `Gulp (silent)`. 

#### Arbitrary task

When running an arbitrary task you need to choose `Gulp: Run arbitrary task` from the command pallete or `Run arbitrary task` from the menu. The package will then prompt an input panel where you can write what you want to add as a sufix to `gulp`.

### Customized Task Access

Out of the box Sublime Gulp has a menu item `Run Default Task` under `Tools -> Gulp` that will run your `default` Gulp task. Most Gulp users have a default task defined (like running their development tasks).

If you want to run other of your tasks from a menu item or [keyboard shortcut](#shortcut-keys) you can customize both.  

For example to add a menu item in the tools menu for a `sass` task do this. In your sublime user directory add following json in the `Main.sublime-menu` file (create one if you don't have one).

```json
{
{'fraction_non_alphanumeric': 0.09681112019623876, 'fraction_numerical': 0.0019623875715453804, 'mean_word_length': 3.680826636050517, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 14, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '35193', 'n_tokens_mistral': 3635, 'n_tokens_neox': 3502, 'n_words': 1672}