Skip to content

Commit

Permalink
refactor: code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jedwards1211 committed Feb 20, 2020
1 parent 19c88ab commit 75323c1
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/getExtractComment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ export default function getExtractComment(
): string | true | null {
for (const { value } of getGraphQLComments(node)) {
if (!value) continue
const parts = value.trim().split(/\s+/g)
const parts = value.trim().split(/\s+/g, 4)
if (parts[0] === pragma && parts[1] === 'extract') {
if (parts[2]) {
if (parts[2] == 'as') {
if (!isValidIdentifier(parts[3])) {
throw new Error(`invalid extract as identifier: ${parts[3]}`)
}
return parts[3]
if (isValidIdentifier(parts[3])) return parts[3]
throw new Error(`invalid extract as identifier: ${parts[3]}`)
} else {
throw new Error(`invalid token after extract: ${parts[2]}`)
}
Expand Down

0 comments on commit 75323c1

Please sign in to comment.