FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
vscode-pull-request-github/scripts/preprocess-gql.js at main · KLevy13/vscode-pull-request-github · GitHub
KLevy13
/
vscode-pull-request-github
Public
forked from
microsoft/vscode-pull-request-github
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
vscode-pull-request-github
/
scripts
/
preprocess-gql.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
44 lines (35 loc) · 1.27 KB
Breadcrumbs
vscode-pull-request-github
/
scripts
/
preprocess-gql.js
Copy path
File metadata and controls
44 lines (35 loc) · 1.27 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const
fs
=
require
(
'fs'
)
;
const
minimist
=
require
(
'minimist'
)
;
const
gqlLoader
=
require
(
'graphql-tag/loader'
)
;
function
printUsage
(
consoleFn
,
exitCode
)
{
consoleFn
(
`Usage: bin/preprocess-gql --in [filename] --out [filename]
Preprocess a file containing GraphQL queries into a *.js module consistently
with the way that Webpack will transpile it at build time.
Options:
--help, -h Display this message.
--in, -i [filename] Read GraphQL queries from the file at [filename].
--out, -o [filename] Emit JavaScript source to the file at [filename].
`
)
;
process
.
exit
(
exitCode
)
;
}
const
argv
=
minimist
(
process
.
argv
.
slice
(
2
)
,
{
string
:
[
'in'
,
'out'
]
,
boolean
:
[
'help'
]
,
alias
:
{
h
:
'help'
,
i
:
'in'
,
o
:
'out'
}
,
unknown
:
param
=>
{
console
.
error
(
`Unrecognized command-line argument:
${
param
}
\n`
)
;
printUsage
(
console
.
error
,
1
)
;
}
,
}
)
;
if
(
argv
.
help
)
{
printUsage
(
console
.
log
,
0
)
;
}
const
inFilename
=
argv
.
in
;
const
outFilename
=
argv
.
out
;
if
(
!
inFilename
||
!
outFilename
)
{
console
.
error
(
'Both --in and --out parameters are required.\n'
)
;
printUsage
(
console
.
error
,
1
)
;
}
const
querySource
=
fs
.
readFileSync
(
inFilename
,
{
encoding
:
'utf8'
}
)
;
const
jsSource
=
gqlLoader
.
call
(
{
cacheable
(
)
{
}
}
,
querySource
)
;
fs
.
writeFileSync
(
outFilename
,
jsSource
,
{
encoding
:
'utf8'
}
)
;
Back
|
FazBrowse Home
|
New Git URL