Skip to content
This repository has been archived by the owner on Nov 3, 2019. It is now read-only.

Commit

Permalink
feat(CLI): mos --init adds mos to the project
Browse files Browse the repository at this point in the history
close #64
  • Loading branch information
zkochan committed May 7, 2016
1 parent 199b64e commit c7c290d
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
38 changes: 36 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ The [readme][] you are currently reading uses mos!
## Table of Contents

- [Installation](#installation)
- [Manual installation](#manual-installation)
- [Usage](#usage)
- [CLI Usage](#cli-usage)
- [mos](#mos)
Expand All @@ -56,13 +57,45 @@ The [readme][] you are currently reading uses mos!
- [Dependencies](#dependencies)
- [Dev Dependencies](#dev-dependencies)

<!--@installation({useShortAlias: true})-->
## Installation

Install mos globally:

```sh
npm i -g mos
```

Make mos configure your `package.json`:

```sh
mos --init
```

Your package.json will be update with some new dependencies and script properties:

```json
{
"name": "awesome-package",
"scripts": {
"test": "mos test",
"md": "mos",
"?md": "echo \"Update the markdown files\""
},
"devDependencies": {
"mos": "^0.17.0"
}
}
```

### Manual installation

You can also install mos directly:

```sh
npm i -D mos
```
<!--/@-->

You'll have to configure the `script` property in your `package.json` to use mos (see above).

## Usage

Expand Down Expand Up @@ -200,6 +233,7 @@ Do you want to write a new one? Read the [plugins readme](./docs/PLUGINS.md).
- [github-url-to-object](https://github.com/zeke/github-url-to-object): Extract user, repo, and other interesting properties from GitHub URLs
- [glob](https://github.com/isaacs/node-glob): a little globber
- [meow](https://github.com/sindresorhus/meow): CLI app helper
- [mos-init](https://github.com/zkochan/mos-init): Add mos to your project
- [mos-plugin-dependencies](https://github.com/zkochan/mos-plugin-dependencies): A mos plugin that creates dependencies sections
- [mos-plugin-example](https://github.com/zkochan/mos-plugin-example): A mos plugin that combines example code files with their output
- [mos-plugin-installation](https://github.com/zkochan/mos-plugin-installation): A mos plugin for creating installation section
Expand Down
8 changes: 8 additions & 0 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const cli = meow([
' mos [test] [files]',
'',
'Options',
' --init Add mos to your project',
' --help, -h Display usage',
' --version, -v Display version',
' --tap Generate TAP output when testing markdown files',
Expand All @@ -37,6 +38,8 @@ const cli = meow([
' mos',
' mos test',
' mos test README.md',
' mos --init',
' mos --init README.md',
'',
'Tips:',
' Add `mos test` to your `scripts.test` property in `package.json`',
Expand All @@ -47,6 +50,11 @@ const cli = meow([
},
})

if (cli.flags.init) {
require('mos-init')()
return // eslint-disable-line
}

const highlightPath = chalk.bgBlack.yellow

const isTest = ~['test', 't'].indexOf((cli.input[0] || '').toLowerCase())
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"github-url-to-object": "~2.2.1",
"glob": "~7.0.3",
"meow": "~3.7.0",
"mos-init": "^1.0.0",
"mos-plugin-dependencies": "^1.0.2",
"mos-plugin-example": "^0.1.0",
"mos-plugin-installation": "^0.2.1",
Expand Down

0 comments on commit c7c290d

Please sign in to comment.