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(
99
99
encoding : 'utf-8' ,
100
100
...options ,
101
101
} ) ;
102
+
103
+ if ( result . status !== 0 ) {
104
+ throw new Error ( `Command failed: ${ command } ${ args . join ( ' ' ) } ` ) ;
105
+ }
106
+
102
107
return result . stdout . toString ( ) . trimEnd ( ) ;
103
108
}
104
109
@@ -107,7 +112,13 @@ function spawn(
107
112
args : ReadonlyArray < string > ,
108
113
options ?: SpawnOptions ,
109
114
) : 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
+ }
111
122
}
112
123
113
124
function * readdirRecursive ( dirPath : string ) : Generator < {
You can’t perform that action at this time.
0 commit comments