File tree 11 files changed +96
-75
lines changed
11 files changed +96
-75
lines changed Original file line number Diff line number Diff line change
1
+ {
2
+ "typescript.tsdk" : " node_modules/typescript/lib"
3
+ }
Original file line number Diff line number Diff line change
1
+ export * from "./lib" ;
Original file line number Diff line number Diff line change
1
+ module . exports = require ( './lib' ) ;
Original file line number Diff line number Diff line change
1
+ module . exports = {
2
+ preset : 'ts-jest' ,
3
+ testEnvironment : 'node'
4
+ } ;
Original file line number Diff line number Diff line change 7
7
" lib/"
8
8
],
9
9
"scripts" : {
10
- "build" : " cross-env NODE_ENV=production babel src --out-dir lib --source-maps " ,
10
+ "build" : " tsc " ,
11
11
"deps" : " dep-check" ,
12
12
"pkg" : " pkg-check" ,
13
- "start" : " concurrently \" ava -c 4 --verbose --watch\" \" yarn run watch\" " ,
14
- "test" : " ava -c 4 --verbose" ,
15
- "watch" : " babel src --out-dir lib --watch --source-maps"
16
- },
17
- "ava" : {
18
- "files" : [
19
- " src/**/*.test.js" ,
20
- " !lib/**/*"
21
- ],
22
- "source" : [
23
- " src/**/*.js" ,
24
- " !lib/**/*"
25
- ],
26
- "babel" : " inherit" ,
27
- "require" : [
28
- " babel-register"
29
- ]
30
- },
31
- "babel" : {
32
- "presets" : [
33
- " babel-preset-commitlint"
34
- ]
13
+ "start" : " concurrently \" yarn test --watchAll\" \" yarn run watch\" " ,
14
+ "test" : " jest" ,
15
+ "watch" : " tsc -w"
35
16
},
36
17
"engines" : {
37
18
"node" : " >=4"
57
38
"license" : " MIT" ,
58
39
"devDependencies" : {
59
40
"@commitlint/parse" : " ^8.0.0" ,
60
- "@commitlint/test" : " ^8.0.0" ,
61
41
"@commitlint/utils" : " ^8.0.0" ,
62
- "ava" : " 0.22.0" ,
63
- "babel-cli" : " 6.26.0" ,
64
- "babel-preset-commitlint" : " ^8.0.0" ,
65
- "babel-register" : " 6.26.0" ,
42
+ "@types/jest" : " 24.0.13" ,
43
+ "@types/lodash" : " 4.14.130" ,
66
44
"concurrently" : " 3.5.1" ,
67
- "cross-env" : " 5.1.1"
68
- },
69
- "dependencies" : {
70
- "babel-runtime" : " 6.26.0"
45
+ "jest" : " 24.8.0" ,
46
+ "ts-jest" : " 24.0.2" ,
47
+ "typescript" : " 3.4.5"
71
48
}
72
- }
49
+ }
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ import execute from '.' ;
2
+
3
+ test ( 'does nothing without params' , async ( ) => {
4
+ const exec = execute as any ;
5
+ expect ( await exec ( ) ) . toBeNull ( ) ;
6
+ } ) ;
7
+
8
+ test ( 'returns plain config' , async ( ) => {
9
+ const actual = await execute ( [ 'name' , 'config' ] ) ;
10
+ expect ( actual ) . toEqual ( [ 'name' , 'config' ] ) ;
11
+ } ) ;
12
+
13
+ test ( 'unwraps promised config' , async ( ) => {
14
+ const actual = await execute ( [ 'name' , Promise . resolve ( 'config' ) ] ) ;
15
+ expect ( actual ) . toEqual ( [ 'name' , 'config' ] ) ;
16
+ } ) ;
17
+
18
+ test ( 'executes config functions' , async ( ) => {
19
+ const actual = await execute ( [ 'name' , ( ) => 'config' ] ) ;
20
+ expect ( actual ) . toEqual ( [ 'name' , 'config' ] ) ;
21
+ } ) ;
22
+
23
+ test ( 'executes async config functions' , async ( ) => {
24
+ const actual = await execute ( [ 'name' , async ( ) => 'config' ] ) ;
25
+ expect ( actual ) . toEqual ( [ 'name' , 'config' ] ) ;
26
+ } ) ;
Original file line number Diff line number Diff line change
1
+ type Rule < T > = readonly [ string , Config < T > ] ;
2
+ type Config < T > = T | Promise < T > | ExectableConfig < T > ;
3
+ type ExectableConfig < T > = ( ( ) => T ) | ( ( ) => Promise < T > ) ;
4
+
5
+ type ExecutedRule < T > = readonly [ string , T ] ;
6
+
7
+ export default execute ;
8
+
9
+ export async function execute < T = unknown > ( rule : Rule < T > ) : Promise < ExecutedRule < T > | null > {
10
+ if ( ! Array . isArray ( rule ) ) {
11
+ return null ;
12
+ }
13
+
14
+ const [ name , config ] = rule ;
15
+
16
+ const fn = executable ( config )
17
+ ? config
18
+ : async ( ) => config ;
19
+
20
+ return [ name , await fn ( ) ] ;
21
+ } ;
22
+
23
+ function executable < T > ( config : Config < T > ) : config is ExectableConfig < T > {
24
+ return typeof config === 'function' ;
25
+ }
Original file line number Diff line number Diff line change
1
+ {
2
+ "compilerOptions" : {
3
+ "lib" : [
4
+ " dom" ,
5
+ " es2015"
6
+ ],
7
+ "rootDir" : " src" ,
8
+ "outDir" : " lib" ,
9
+ "declaration" : true ,
10
+ "declarationMap" : true ,
11
+ "sourceMap" : true ,
12
+ "esModuleInterop" : true ,
13
+ "allowSyntheticDefaultImports" : true ,
14
+ "strict" : true
15
+ },
16
+ "include" : [
17
+ " ./src"
18
+ ],
19
+ "exclude" : [
20
+ " ./src/**/*.test.ts"
21
+ ]
22
+ }
Original file line number Diff line number Diff line change 38
38
"license" : " MIT" ,
39
39
"devDependencies" : {
40
40
"@commitlint/test" : " ^8.0.0" ,
41
- "@commitlint/utils" : " ^8.0.0" ,
42
- "@types/jest" : " 24.0.12" ,
41
+ "@types/jest" : " 24.0.13" ,
43
42
"@types/lodash" : " 4.14.133" ,
44
43
"concurrently" : " 3.5.1" ,
45
- "cross-env" : " 5.1.1" ,
46
- "jest" : " 24.7.1" ,
47
- "rimraf" : " 2.6.1" ,
44
+ "jest" : " 24.8.0" ,
48
45
"ts-jest" : " 24.0.2" ,
49
- "typescript" : " 3.5.1"
46
+ "typescript" : " 3.5.1" ,
47
+ "lodash" : " 4.17.11"
50
48
},
51
49
"dependencies" : {
52
50
"chalk" : " ^2.0.1"
You can’t perform that action at this time.
0 commit comments