Giter Club home page Giter Club logo

maid's Introduction

maid

NPM version NPM downloads CircleCI donate chat

Markdown driven task runner.

Install

npm i -g maid

What is a maidfile?

A maidfile is where you define tasks, in Markdown!

๐Ÿ“ maidfile.md:

## lint

> Run ESLint to ensure code quality

```bash
eslint --fix
```

## build

> Build our main app
> Run `build:demo` after this

```bash
# note that you can directly call binaries inside node_modules/.bin
# just like how `npm scripts` works
babel src -d lib
```

## build:demo

> Run a custom build script which is written in JS for the demo!

```js
const webpack = require('webpack')

const compiler = webpack(require('./webpack.config'))
compiler.run((err, stats) => {
  console.log(err || stats.toString('minimal'))
})
```

Each task is defined as a heading 2 section, the value of heading 2 will be used as task name, the following blockquote (optional) will be used as task description, the following code block (required) will be used as task script.

Currently the code block language can be sh bash js javascript.

Now run maid help to display the help for this maidfile:

โฏ maid help

  lint        Run ESLint to ensure code quality
  build       Build our main app
  build:demo  Run a custom build script which is written in JS for the demo!

โฏ maid help "build*"

  build       Build our main app
  build:demo  Run a custom build script which is written in JS for the demo!

To run a task, you can directly run maid <task_name>

โฏ maid build
[13:46:38] Starting 'build'...
๐ŸŽ‰  Successfully compiled 3 files with Babel.
[13:46:38] Finished 'build' after 363 ms...

# to get minimal logs
โฏ maid build --quiet
๐ŸŽ‰  Successfully compiled 3 files with Babel.

Run tasks before/after a task

You can even run tasks before or after a task:

## build

> Run `deploy` after this

```bash
webpack --config config/webpack.config.js
```

## deploy

```bash
gh-pages -d dist
```

Basically blockquotes like Run `deploy` after this is treated specicially, in this case it says run the task deploy after this task is finished.

The syntax is simple: Run <taskNames> (before|after) this (in parallel?) where each task name is surrounded by a pair of backticks: `.

Task hooks

Like npm scripts, when you run a command called build, when it's finised we will also run postbuild task.

Hook syntax:

  • pre<taskName>: Run before a specific task.
  • post<taskName>: Run after a specific task.
  • afterAll: Run after all tasks.
  • beforeAll: Run before all tasks.

Asynchronous task

For task script that is written in JavaScript, you can export a function which returns Promise:

## build

```js
module.exports = async () => {
  const files = await readFiles('./')
  await buildFiles(files)
}
```

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Author

maid ยฉ egoist, Released under the MIT License.
Authored and maintained by egoist with help from contributors (list).

github.com/egoist ยท GitHub @egoist ยท Twitter @_egoistlily

maid's People

Contributors

egoist avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.