https://github.com/mkdoc/mkmsg
Message injection
https://github.com/mkdoc/mkmsg
Last synced: about 1 year ago
JSON representation
Message injection
- Host: GitHub
- URL: https://github.com/mkdoc/mkmsg
- Owner: mkdoc
- License: other
- Archived: true
- Created: 2016-03-16T12:19:14.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-04-18T03:58:37.000Z (about 10 years ago)
- Last Synced: 2025-04-23T22:56:25.094Z (about 1 year ago)
- Language: JavaScript
- Size: 31.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Message
[](https://travis-ci.org/mkdoc/mkmsg)
[](https://npmjs.org/package/mkmsg)
[](https://coveralls.io/github/mkdoc/mkmsg?branch=master)
> Append or prepend a message
By default appends a message to a stream, use the `message` option to change the message; to prepend set the `prepend` option.
When no message is given the default generator message is used.
## Install
```
npm i mkmsg --save
```
For the command line interface install [mkdoc][] globally (`npm i -g mkdoc`).
---
- [Install](#install)
- [Usage](#usage)
- [Example](#example)
- [Help](#help)
- [API](#api)
- [msg](#msg)
- [Options](#options)
- [License](#license)
---
## Usage
Create the stream and write a [commonmark][] document:
```javascript
var msg = require('mkmsg')
, ast = require('mkast');
ast.src('This is a markdown paragraph.')
.pipe(msg())
.pipe(ast.stringify({indent: 2}))
.pipe(process.stdout);
```
## Example
Append the default generator message:
```shell
mkcat README.md | mkmsg | mkout
```
Append a custom message:
```shell
mkcat README.md | mkmsg -m "Commit: $(git rev-parse HEAD)" | mkout
```
Prepend a custom message:
```shell
mkcat README.md | mkmsg -p -m "Commit: $(git rev-parse HEAD)" | mkout
```
## Help
```
Usage: mkmsg [options]
Message injection.
Options
-m, --message=[MSG] Custom message, parsed as markdown
-p, --prepend Prepend message to the stream
-h, --help Display help and exit
--version Print the version and exit
mkmsg@1.2.5
```
## API
### msg
```javascript
msg([opts][, cb])
```
Append or prepend a message string.
The message string is parsed as markdown and written to the end of the
document unless `prepend` is given.
The document node itself is omitted; it's content nodes are written to
the stream.
Returns an output stream.
* `opts` Object processing options.
* `cb` Function callback function.
#### Options
* `input` Readable input stream.
* `output` Writable output stream.
* `message` String markdown message.
* `prepend` Boolean prepend message to the stream.
## License
MIT
---
Created by [mkdoc](https://github.com/mkdoc/mkdoc) on April 18, 2016
[mkdoc]: https://github.com/mkdoc/mkdoc
[mkparse]: https://github.com/mkdoc/mkparse
[commonmark]: http://commonmark.org
[jshint]: http://jshint.com
[jscs]: http://jscs.info