File tree Expand file tree Collapse file tree 3 files changed +5
-11
lines changed Expand file tree Collapse file tree 3 files changed +5
-11
lines changed Original file line number Diff line number Diff line change 9
9
# https://github.com/TypeStrong/ts-node/issues/935#issuecomment-582673034
10
10
#
11
11
12
-
13
12
node --loader @k-foss/ts-esnode --experimental-specifier-resolution=node $@
Original file line number Diff line number Diff line change 12
12
"train" : " bin/tsnode src/net/train.js" ,
13
13
"test-model" : " node src/net/check_model.js" ,
14
14
"tsc" : " tsc" ,
15
- "test" : " mocha --require ts-node/register src/**/*.spec.ts"
15
+ "test" : " bin/tsnode node_modules/mocha/bin/_mocha src/**/*.spec.ts"
16
16
},
17
17
"keywords" : [
18
18
" snake" ,
Original file line number Diff line number Diff line change @@ -11,7 +11,6 @@ import {worldToVector} from './worldToVector'
11
11
const width = 20 ;
12
12
const height = 20 ;
13
13
14
-
15
14
const render = ( world : IWorld ) => {
16
15
const { width } = world ;
17
16
const inputVector = worldToVector ( world ) ;
@@ -23,9 +22,10 @@ const render = (world: IWorld) => {
23
22
}
24
23
}
25
24
}
26
- const world = createWorld ( width , height ) ;
27
25
28
- const playGame = async function ( ) {
26
+ process . env . NODE && ( async ( ) => {
27
+ const world = createWorld ( width , height ) ;
28
+
29
29
let alive = true ;
30
30
while ( alive ) {
31
31
render ( world ) ;
@@ -35,9 +35,4 @@ const playGame = async function() {
35
35
world . player . headed = arrowKeys [ direction ] ;
36
36
await sleep ( 500 ) ;
37
37
}
38
-
39
- } ;
40
-
41
- if ( process . env . NODE ) {
42
- playGame ( ) ;
43
- }
38
+ } ) ( ) ;
You can’t perform that action at this time.
0 commit comments