Skip to content

Commit 1051d8f

Browse files
author
max
committed
feat(init): Initial commit
0 parents  commit 1051d8f

File tree

8 files changed

+226
-0
lines changed

8 files changed

+226
-0
lines changed

.babelrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": [ "es2015" ]
3+
}

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules
2+
coverage
3+
dist
4+
*.log
5+
*.swp
6+
*~

.travis.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
sudo: false
2+
language: node_js
3+
cache:
4+
directories:
5+
- node_modules
6+
notifications:
7+
email: false
8+
node_js:
9+
- '5'
10+
before_install:
11+
- npm i -g npm@^3.8.5
12+
before_script:
13+
- npm prune
14+
script:
15+
- npm run test:single
16+
- npm run check-coverage
17+
- npm run build
18+
after_success:
19+
- npm run report-coverage
20+
- npm run semantic-release
21+
branches:
22+
only:
23+
- master

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2016 subk
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
vorpal-comment
2+
==============
3+
4+
[![Travis](https://img.shields.io/travis/subk/vorpal-comment.svg)](https://travis-ci.org/subk/vorpal-comment)
5+
[![Codecov](https://img.shields.io/codecov/c/github/subk/vorpal-comment.svg?maxAge=2592000)](https://codecov.io/github/subk/vorpal-comment)
6+
[![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
7+
8+
Bash-like comments for [Vorpal.js](http://vorpal.js.org/)
9+
10+
## Installation
11+
```bash
12+
$ npm i vorpal-comment
13+
```
14+
15+
## Usage
16+
```javascript
17+
import Vorpal from 'vorpal';
18+
import comment from 'vorpal-comment';
19+
20+
const vorpal = new Vorpal();
21+
22+
vorpal
23+
.use(comment)
24+
.delimiter('example>')
25+
.show();
26+
```
27+
```bash
28+
example> # im a comment
29+
example>
30+
```
31+
32+
## Options
33+
```javascript
34+
const options = {
35+
command: '//', // comments start with // instead of #
36+
alias: [ '--', '<<' ] // define some aliases
37+
}
38+
vorpal.use(comment, options);
39+
```
40+
## License
41+
MIT

package.json

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
{
2+
"name": "vorpal-comment",
3+
"description": "Bash-like comments for Vorpal.js",
4+
"main": "./dist/comment.js",
5+
"scripts": {
6+
"prebuild": "rimraf dist",
7+
"build": "babel src -d dist",
8+
"check-coverage": "istanbul check-coverage --statements 100 --functions 100 --lines 100",
9+
"report-coverage": "cat ./coverage/lcov.info | codecov",
10+
"test": "mocha -w --compilers js:babel-register test/test.js",
11+
"test:single": "istanbul cover _mocha -- -R spec --report lcovonly --compilers js:babel-register test/test.js",
12+
"semantic-release": "semantic-release pre && npm publish && semantic-release post",
13+
"commit": "git-cz"
14+
},
15+
"repository": {
16+
"type": "git",
17+
"url": "https://github.com/subk/vorpal-comment.git"
18+
},
19+
"keywords": [
20+
"vorpal",
21+
"comment",
22+
"bash"
23+
],
24+
"author": "kbus",
25+
"license": "MIT",
26+
"bugs": {
27+
"url": "https://github.com/subk/vorpal-comment/issues"
28+
},
29+
"files": [
30+
"dist",
31+
"README.md"
32+
],
33+
"homepage": "https://github.com/subk/vorpal-comment#readme",
34+
"devDependencies": {
35+
"babel-cli": "^6.6.5",
36+
"babel-preset-es2015": "^6.6.0",
37+
"chai": "^3.5.0",
38+
"codecov.io": "^0.1.6",
39+
"commitizen": "^2.7.6",
40+
"cz-conventional-changelog": "^1.1.5",
41+
"istanbul": "^1.0.0-alpha.2",
42+
"mocha": "^2.4.5",
43+
"rimraf": "^2.5.2",
44+
"semantic-release": "^4.3.5",
45+
"test-console": "^1.0.0",
46+
"vorpal": "^1.10.10"
47+
},
48+
"config": {
49+
"commitizen": {
50+
"path": "node_modules/cz-conventional-changelog"
51+
},
52+
"ghooks": {
53+
"pre-commit": "npm run test:single && npm run check-coverage"
54+
}
55+
}
56+
}

src/comment.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import Vorpal from 'vorpal';
2+
3+
export default function (vorpal, options = { command: '#' }) {
4+
const comment = vorpal.command(options.command, 'A comment line');
5+
if (options.alias) {
6+
comment.alias(options.alias);
7+
}
8+
comment
9+
.hidden()
10+
.action(function (args, callback) {
11+
callback();
12+
});
13+
}

test/test.js

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import { expect } from 'chai';
2+
import comment from '../src/comment';
3+
import Vorpal from 'vorpal';
4+
import { stdout } from 'test-console';
5+
6+
describe('vorpal-comment', function() {
7+
8+
it('should be properly imported as a function', () => {
9+
expect(comment).to.be.instanceof(Function);
10+
});
11+
12+
it('should be imported by Vorpal', () => {
13+
expect(() => {
14+
new Vorpal().use(comment);
15+
new Vorpal().use(comment, { command: '!' });
16+
new Vorpal().use(comment, { alias: '//' });
17+
new Vorpal().use(comment, { command: '!', alias: '//' });
18+
new Vorpal().use(comment, { command: '!', alias: [ '//', '--', '<<' ] });
19+
}).to.not.throw();
20+
});
21+
22+
it('should allow comments starting with #', () => {
23+
const output = stdout.inspectSync(() => {
24+
const vorpal = new Vorpal();
25+
vorpal.use(comment);
26+
vorpal.exec('# a comment line');
27+
});
28+
// no output
29+
expect(output).to.have.length(0);
30+
});
31+
32+
it('should allow comments starting with ? instead of #', () => {
33+
const output = stdout.inspectSync(() => {
34+
const vorpal = new Vorpal();
35+
vorpal.use(comment, { command: '?' });
36+
vorpal.exec('? a comment line');
37+
});
38+
// no output
39+
expect(output).to.have.length(0);
40+
});
41+
42+
it('should allow comments starting with an alias of //', () => {
43+
const output = stdout.inspectSync(() => {
44+
const vorpal = new Vorpal();
45+
vorpal.use(comment, { alias: '//' });
46+
vorpal.exec('// a comment line');
47+
});
48+
// no output
49+
expect(output).to.have.length(0);
50+
});
51+
52+
it('should allow comments starting with aliases of // -- <<', () => {
53+
const output = stdout.inspectSync(() => {
54+
const vorpal = new Vorpal();
55+
vorpal.use(comment, { alias: [ '//', '--', '<<' ] });
56+
vorpal.exec('// a comment line');
57+
vorpal.exec('-- a comment line');
58+
vorpal.exec('<< a comment line');
59+
});
60+
// no output
61+
expect(output).to.have.length(0);
62+
});
63+
});

0 commit comments

Comments
 (0)