-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from xpepermint/master
Support package.json configuration, fix return codes
- Loading branch information
Showing
17 changed files
with
161 additions
and
46 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
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
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
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
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
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,26 @@ | ||
import * as pt from 'path'; | ||
|
||
/** | ||
* Returns package.json data. | ||
*/ | ||
export function getPackage() { | ||
try { | ||
return require(pt.join(process.cwd(), 'package.json')) || {}; | ||
} catch (e) { | ||
return {}; | ||
} | ||
} | ||
|
||
/** | ||
* Returns Hayspec options. | ||
*/ | ||
export function getConfig(argv?: any) { | ||
const defaults = getPackage()['hayspec'] || {}; | ||
const custom = argv || {}; | ||
return { | ||
name: custom['name'] || defaults['name'] || '', | ||
description: custom['description'] || defaults['description'] || '', | ||
require: custom['require'] || defaults['require'] || [], | ||
match: custom['match'] || defaults['match'] || [], | ||
}; | ||
} |
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
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,14 @@ | ||
import { Spec } from '@hayspec/spec'; | ||
|
||
const spec = new Spec(); | ||
|
||
spec.test('foo', async (context) => { | ||
context.true(true); | ||
}); | ||
|
||
spec.test('bar', async (context) => { | ||
context.true(true); | ||
context.true(true); | ||
}); | ||
|
||
export default spec; |
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
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,24 @@ | ||
import test from 'ava'; | ||
import { getConfig } from '../../lib/env'; | ||
|
||
test('method `getConfig` returns package.json hayspec configuration', async (t) => { | ||
t.deepEqual(getConfig(), { | ||
name: '', | ||
description: '', | ||
require: ['ts-node/register'], | ||
match: ['./src/**/*.hay.*'], | ||
}); | ||
}); | ||
|
||
test('method `getConfig` merges reveived configuration', async (t) => { | ||
t.deepEqual(getConfig({ | ||
extension: [], | ||
require: ['bar'], | ||
match: ['foo'], | ||
}), { | ||
name: '', | ||
description: '', | ||
require: ['bar'], | ||
match: ['foo'], | ||
}); | ||
}); |
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
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
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
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
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
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
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 |
---|---|---|
|
@@ -50,7 +50,6 @@ export class Reporter { | |
*/ | ||
public end() { | ||
this.onEnd(); | ||
this.reset(); | ||
} | ||
|
||
/** | ||
|