Skip to content

Instantly share code, notes, and snippets.

@agrublev
Created March 4, 2019 04:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agrublev/7868d1afe76c2ac68bfe35e023966f2c to your computer and use it in GitHub Desktop.
Save agrublev/7868d1afe76c2ac68bfe35e023966f2c to your computer and use it in GitHub Desktop.

The simplest way to run your npm type tasks

You write a beautiful & documented Markdown file, we run it for you. And you have a lot of flexibility!

Example FcScripts.md file

Or if you want to ensure that your teammates are using the same version as you, it's recommended to install Maid locally:

# For npm users
npm i -D maid
# For Yarn users
yarn add maid --dev

PRO TIP: you can use npx or yarn command to run any locally installed executable that is inside node_modules/.bin/, e.g. use yarn maid to run the locally installed maid command.

What is a maidfile?

A maidfile is where you define tasks, in Markdown!

📝 maidfile.md:

## lint

It uses ESLint to ensure code quality.

```bash
eslint --fix
```

## build

Build our main app

<!-- Following line is a maid command for running task -->

Run task `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

You can use JavaScript to write to task script too!

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

// Async task should return a Promise
module.exports = () =>
  new Promise((resolve, reject) => {
    const compiler = webpack(require('./webpack.config'))
    compiler.run((err, stats) => {
      if (err) return reject(err)
      console.log(stats.toString('minimal'))
      resolve()
    })
  })
```

Each task is defined using h2 header and its child contents, the value of h2 header will be used as task name, its following paragraphs (optional) will be used as task description, and following code block (optional) will be used as task script.

# Start Scripts

Start running in development mode

## start:w:u

Run tasks `start:web` and `start:utils` in parallel.

## start:web

Start web with parcel

```bash
NODE_ENV=development lerna --scope=web run start --stream --

start:utils

NODE_ENV=development lerna --scope=utils run start --stream --

Build Scripts

Build our app

build

Build our main app

Run task build:demo after this

# note that you can directly call binaries inside node_modules/.bin
# just like how `npm scripts` works
babel src -d lib
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment