Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5181e62
commit bae50c3
Showing
10 changed files
with
631 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# editorconfig.org | ||
root = true | ||
|
||
[*] | ||
indent_size = 2 | ||
indent_style = space | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false | ||
|
||
[*.edge] | ||
insert_final_newline = false | ||
trim_trailing_whitespace=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
coverage | ||
node_modules | ||
.DS_Store | ||
npm-debug.log | ||
.idea | ||
dump.rdb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
coverage | ||
node_modules | ||
.DS_Store | ||
npm-debug.log | ||
test | ||
dump.rdb | ||
.travis.yml | ||
.editorconfig | ||
benchmarks | ||
.idea | ||
bin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Japa CLI | ||
|
||
The CLI runner for [https://github.com/thetutlage/japa](Japa). | ||
|
||
## Usage | ||
|
||
```bash | ||
npm i -g japa-cli | ||
|
||
# Help | ||
japa --help | ||
|
||
# Run tests | ||
japa | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
'use strict' | ||
|
||
/* | ||
* japa-cli | ||
* | ||
* (c) Harminder Virk <virk@adonisjs.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
class JapaCli { | ||
constructor () { | ||
this._initiate() | ||
} | ||
|
||
/** | ||
* Initiate private and public properties | ||
* | ||
* @method _initiate | ||
* | ||
* @return {void} | ||
* | ||
* @private | ||
*/ | ||
_initiate () { | ||
this._timeout = null | ||
this._grep = null | ||
this._bail = false | ||
|
||
// public | ||
this.filterCallback = null | ||
this.ignorePattern = [] | ||
this.testsGlob = 'test/*.spec.js' | ||
} | ||
|
||
/** | ||
* Filter files to be used for running the tests. You can | ||
* return a string, an array of globs or a function | ||
* which is called for each file. | ||
* | ||
* @method filter | ||
* | ||
* @param {String|Array|Function} patternOrCallback | ||
* | ||
* @chainable | ||
*/ | ||
filter (patternOrCallback) { | ||
if (typeof (patternOrCallback) === 'function') { | ||
this.filterCallback = patternOrCallback | ||
return this | ||
} | ||
|
||
if (typeof (patternOrCallback) === 'string') { | ||
this.ignorePattern = [patternOrCallback] | ||
return this | ||
} | ||
|
||
if (patternOrCallback instanceof Array === true) { | ||
this.ignorePattern = patternOrCallback | ||
return this | ||
} | ||
|
||
throw new Error('japaCli.filter only excepts a glob string, array or a callback function') | ||
} | ||
|
||
/** | ||
* Set global timeout on each test | ||
* | ||
* @method timeout | ||
* | ||
* @param {Number} timeout | ||
* | ||
* @chainable | ||
*/ | ||
timeout (timeout) { | ||
this._timeout = Number(timeout) | ||
return this | ||
} | ||
|
||
/** | ||
* Whether or not to exist tests earlier. Passed | ||
* to japa runner | ||
* | ||
* @method bail | ||
* | ||
* @param {Boolean} status | ||
* | ||
* @chainable | ||
*/ | ||
bail (status) { | ||
this._bail = !!status | ||
return this | ||
} | ||
|
||
/** | ||
* The pattern to be used for grepping over | ||
* tests. Passed to japa runner | ||
* | ||
* @method grep | ||
* | ||
* @param {String} pattern | ||
* | ||
* @chainable | ||
*/ | ||
grep (pattern) { | ||
this._grep = pattern | ||
return this | ||
} | ||
|
||
/** | ||
* Set the glob to be used for picking tests | ||
* files and then running the tests. | ||
* | ||
* @method run | ||
* | ||
* @param {String} glob | ||
* | ||
* @return {void} | ||
*/ | ||
run (glob) { | ||
if (!glob) { | ||
return | ||
} | ||
|
||
if (typeof (glob) !== 'string') { | ||
throw new Error(`japaCli.run excepts glob pattern to be a string. You passed ${typeof (glob)}`) | ||
} | ||
|
||
this.testsGlob = glob | ||
} | ||
} | ||
|
||
module.exports = new JapaCli() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
"name": "japa-cli", | ||
"version": "1.0.0", | ||
"description": "const japaCli = require('japaCli')", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "amanvirk,adonisjs", | ||
"license": "MIT", | ||
"dependencies": { | ||
"commander": "^2.9.0", | ||
"globby": "^6.1.0" | ||
}, | ||
"devDependencies": { | ||
"clear-require": "^2.0.0", | ||
"cz-conventional-changelog": "^2.0.0", | ||
"japa": "^1.0.1", | ||
"pify": "^2.3.0" | ||
}, | ||
"directories": { | ||
"test": "test" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/thetutlage/japa-cli.git" | ||
}, | ||
"keywords": [ | ||
"japa", | ||
"test-runner", | ||
"tests" | ||
], | ||
"bugs": { | ||
"url": "https://github.com/thetutlage/japa-cli/issues" | ||
}, | ||
"bin": { | ||
"japa": "./src/bin.js" | ||
}, | ||
"homepage": "https://github.com/thetutlage/japa-cli#readme", | ||
"config": { | ||
"commitizen": { | ||
"path": "./node_modules/cz-conventional-changelog" | ||
} | ||
} | ||
} |
Oops, something went wrong.