File tree Expand file tree Collapse file tree 1 file changed +15
-9
lines changed
packages/store/src/cli/commands/store Expand file tree Collapse file tree 1 file changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -22,15 +22,7 @@ export default class Execute extends Command {
2222 async run ( ) : Promise < void > {
2323 const { flags} = await this . parse ( Execute )
2424
25- let query = flags . query
26-
27- if ( ! query && flags [ 'query-file' ] ) {
28- query = await readFile ( flags [ 'query-file' ] )
29- }
30-
31- if ( ! query ) {
32- this . error ( 'either --query or --query-file is required' )
33- }
25+ const query = await this . getQuery ( flags )
3426
3527 const store = flags . store
3628 if ( ! store ) {
@@ -74,4 +66,18 @@ export default class Execute extends Command {
7466
7567 this . log ( JSON . stringify ( result , null , 2 ) )
7668 }
69+
70+ private async getQuery ( flags : { query ?: string ; 'query-file' ?: string } ) : Promise < string > {
71+ let query = flags . query
72+
73+ if ( ! query && flags [ 'query-file' ] ) {
74+ query = await readFile ( flags [ 'query-file' ] )
75+ }
76+
77+ if ( ! query ) {
78+ this . error ( 'either --query or --query-file is required' )
79+ }
80+
81+ return query
82+ }
7783}
You can’t perform that action at this time.
0 commit comments