# steamer-plugin-task

> run tasks parallelly or serially

Latest version **1.0.5** (published 2018-05-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install steamer-plugin-task
pnpm add steamer-plugin-task
yarn add steamer-plugin-task
bun add steamer-plugin-task
```

Provides the command `steamer-plugin-task`.

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2018-05-07 |
| First published | 2017-12-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 21.3 KB |
| Known vulnerabilities | 0 (+6 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | steamerjs |
| Maintainers | lcxfs1991 |
| Keywords | steamer, example |

## Links

- npm: https://www.npmjs.com/package/steamer-plugin-task
- Repository: https://github.com/steamerjs/steamer-plugin-task
- Homepage: https://github.com/steamerjs/steamer-plugin-task#readme
- Issues: https://github.com/steamerjs/steamer-plugin-task/issues
- npm.io page: https://npm.io/package/steamer-plugin-task

## Dependencies (4)

- [inquirer](https://npm.io/package/inquirer.md) ^5.2.0
- [simple-git](https://npm.io/package/simple-git.md) ^1.92.0
- [cross-spawn](https://npm.io/package/cross-spawn.md) ^6.0.5
- [steamer-plugin](https://npm.io/package/steamer-plugin.md) ^1.0.4

## Recent versions

- 1.0.5 (latest) — 2018-05-07
- 1.0.4 — 2017-12-07
- 1.0.3 — 2017-12-06
- 1.0.2 — 2017-12-06
- 1.0.1 — 2017-12-05
- 1.0.0 — 2017-12-05

## README

# steamer-plugin-task

并行或串行执行自定义任务

[![NPM Version](https://img.shields.io/npm/v/steamer-plugin-task.svg?style=flat)](https://www.npmjs.com/package/steamer-plugin-task)
[![Travis](https://img.shields.io/travis/steamerjs/steamer-plugin-task.svg)](https://travis-ci.org/steamerjs/steamer-plugin-task)
[![Deps](https://david-dm.org/steamerjs/steamer-plugin-task.svg)](https://img.shields.io/steamerjs/steamer-plugin-task)
[![Coverage](https://img.shields.io/coveralls/steamerjs/steamer-plugin-task.svg)](https://coveralls.io/github/steamerjs/steamer-plugin-task)

## 添加任务
```javascript
steamer task --add [task name]

// 如：
steamer task --add alloyteam
// 1. 全局安装 steamer-task-alloyteam
// 2. 将 steamer-task-alloyteam 里的 .steamer 内容全数拷贝到项目的 .steamer内
// 3. 安装 steamer-task-alloyteam 任务所需依赖到项目中
```

## 任务配置
```javascript
// 自动生成配置
steamer task

// .steamer/steamer-plugin-task.js
/**
 * 如果 task 是一个文件路径字符串，并且存在，文件会被 require 之后，执行
 * 如果 task 是字符串且中间有空格分割，task 会被解析成命令行，直接用 spawn 执行
 */
module.exports = {
    "plugin": "steamer-plugin-task",
    "config": {
        // 用对象写法是并行运行命令
        "dev": {
            0: "steamer list",
            1: "cde.js",
        },
        // 用数组写法是串行运行命令
        "dist": [
            "steamer kit -l",
            "bcd.js",
            "abc.js"
        ]
    }
};

// .steamer/task
task
 |-- abc.js
 |-- bcd.js
 |-- cde.js
 |-- def.js

// 并行任务
// cde.js
module.exports = function (ctx) {
    console.log('cde');
};

// def.js
module.exports = function (ctx) {
    console.log('def');
};

// 串行任务
// bcd.js
module.exports = function(ctx, next) {
    console.log('bcd');
    next();
};

// abc.js, 最后一个任务无须执行next
module.exports = function(ctx) {
    console.log('abc');
};

```

## 并行或串行运行任务
```javascript
// 并行运行 dev 的命令
steamer task dev
start running task: steamer list
start running task: cde.js
// output from node cde.js
finishing task: cde.js
// output from steamer list
finishing task: steamer list

// 串行运行 dist 的命令
start running task: steamer kit -l
// output from steamer list
steamer task dist
start running task: bcd.js
// 1 second later
// output from node bcd.js
start running task: abc.js
// out from node abc.js
```

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