# grunt-anon-tasks

> Run anonymous Grunt tasks.

Latest version **0.2.2** (published 2015-03-18) · 0 weekly downloads

## Install

```sh
npm install grunt-anon-tasks
pnpm add grunt-anon-tasks
yarn add grunt-anon-tasks
bun add grunt-anon-tasks
```

## Health

**Score 10/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; low quality score; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.2 |
| Published | 2015-03-18 |
| First published | 2015-03-10 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 13 |
| Author | Alec Larson |
| Maintainers | aleclarson |
| Keywords | grunt, gruntplugin |

## Links

- npm: https://www.npmjs.com/package/grunt-anon-tasks
- Repository: https://github.com/aleclarson/grunt-anon-tasks
- Issues: https://github.com/aleclarson/grunt-anon-tasks/issues
- npm.io page: https://npm.io/package/grunt-anon-tasks

## Recent versions

- 0.2.2 (latest) — 2015-03-18
- 0.2.1 — 2015-03-18
- 0.2.0 — 2015-03-14
- 0.1.2 — 2015-03-10
- 0.1.1 — 2015-03-10

## README

## grunt-anon-tasks v0.2.2

**What is this?**

A plugin for [Grunt](http://gruntjs.com/) that allows you to create **anonymous tasks** using `grunt.task.then()`.

**What's an anonymous task?** 

A task that you can run without ever calling `grunt.registerTask()` manually. Anonymous tasks are extremely useful for (1) completion callbacks and (2) dynamic task configuration.

-

#### Table of Contents

&nbsp;&nbsp;&nbsp;&nbsp;
[Installation](#installation)

&nbsp;&nbsp;&nbsp;&nbsp;
[Example](#example)

&nbsp;&nbsp;&nbsp;&nbsp;
[Descriptions](#descriptions)

&nbsp;&nbsp;&nbsp;&nbsp;
[Failability](#failability)

&nbsp;&nbsp;&nbsp;&nbsp;
[Lifecycle](#lifecycle)

-

#### Installation

In your terminal:

```
npm install --save-dev grunt-anon-tasks
```

In your `Gruntfile.js`:

```Javascript
grunt.loadNpmTasks("grunt-anon-tasks")
```

But I suggest using [`load-grunt-tasks`](https://github.com/sindresorhus/load-grunt-tasks):

```Javascript
require("load-grunt-tasks")(grunt) // loads every installed "grunt-*" module
```

-

#### Example

In the example below, the anonymous task runs after `clean` completes and before `build` starts.

```Javascript
grunt.task
  .run("clean")
  .then(function () {
    grunt.log.writeln(this.name)
  })
  .run("build")
```

The `this` variable in anonymous tasks is the same [as in registered tasks](http://gruntjs.com/api/inside-tasks).

-

#### Descriptions

Debugging is easier when an anonymous task has a description. Of course, this is optional.

```Javascript
grunt.task.then("A description of what I'm doing", function () {
  // do cool grunty things
})
```

If provided, the description will appear in your terminal (below the message that says `Running "anon_x" task`).

-

#### Failability

Anonymous tasks can signal failure either synchronously or asynchronously; just like registered tasks.

```Javascript
grunt.task
  .then(function () {
    return false // synchronous failure
  })
  .then(function () {
    var done = this.async()
    performAsyncOperation(function () {
      done(false) // asynchronous failure
    })
  })
```

-

#### Lifecycle

Anonymous tasks are deleted after completion; thus, it isn't possible to run the same anonymous task more than once.

---
_Source: https://npm.io/package/grunt-anon-tasks · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
