File tree Expand file tree Collapse file tree 2 files changed +38
-1
lines changed
Expand file tree Collapse file tree 2 files changed +38
-1
lines changed Original file line number Diff line number Diff line change 1+ const assert = require ( 'assert' ) ;
2+ const { readFileSync } = require ( 'fs' ) ;
3+
4+ const { graphqlSync } = require ( 'graphql' ) ;
5+ const { buildSchema } = require ( 'graphql/utilities' ) ;
6+ const { version } = require ( 'graphql/version' ) ;
7+
8+ assert . deepStrictEqual (
9+ version ,
10+ JSON . parse ( readFileSync ( './node_modules/graphql/package.json' ) ) . version ,
11+ ) ;
12+
13+ const schema = buildSchema ( 'type Query { hello: String }' ) ;
14+
15+ const result = graphqlSync ( {
16+ schema,
17+ source : '{ hello }' ,
18+ rootValue : { hello : 'world' } ,
19+ } ) ;
20+
21+ assert . deepStrictEqual ( result , {
22+ data : {
23+ __proto__ : null ,
24+ hello : 'world' ,
25+ } ,
26+ } ) ;
Original file line number Diff line number Diff line change @@ -99,6 +99,11 @@ function spawnOutput(
9999 encoding : 'utf-8' ,
100100 ...options ,
101101 } ) ;
102+
103+ if ( result . status !== 0 ) {
104+ throw new Error ( `Command failed: ${ command } ${ args . join ( ' ' ) } ` ) ;
105+ }
106+
102107 return result . stdout . toString ( ) . trimEnd ( ) ;
103108}
104109
@@ -107,7 +112,13 @@ function spawn(
107112 args : ReadonlyArray < string > ,
108113 options ?: SpawnOptions ,
109114) : void {
110- childProcess . spawnSync ( command , args , { stdio : 'inherit' , ...options } ) ;
115+ const result = childProcess . spawnSync ( command , args , {
116+ stdio : 'inherit' ,
117+ ...options ,
118+ } ) ;
119+ if ( result . status !== 0 ) {
120+ throw new Error ( `Command failed: ${ command } ${ args . join ( ' ' ) } ` ) ;
121+ }
111122}
112123
113124function * readdirRecursive ( dirPath : string ) : Generator < {
You can’t perform that action at this time.
0 commit comments