-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Glob and multiple schema pointers as
schema: **/*.graphqls
(#142)
* It works. All pass * fix: should include configHash - Update snapshots * README.md * removing __generated__ in "yarn clean" doesn't make sense * fix: Care CRLF before creating hash * The order must always be same
- Loading branch information
1 parent
3f2a3d5
commit 3802ece
Showing
20 changed files
with
306 additions
and
416 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,20 @@ | ||
import { EOL } from 'os'; | ||
import crypto from 'crypto'; | ||
|
||
const shouldCareNewline = EOL !== '\n'; | ||
const RegexCRLF = /\r\n/g; | ||
function normalizeNewline(input: string | Buffer): string { | ||
const str = Buffer.isBuffer(input) ? input.toString() : input; | ||
if (shouldCareNewline) return str.replace(RegexCRLF, '\n'); | ||
return str; | ||
} | ||
|
||
export function createHash(s: string | Buffer): string { | ||
return crypto | ||
.createHash('sha1') | ||
.update((Buffer.isBuffer(s) ? s.toString() : s).replace(/\r\n/g, '\n')) | ||
.digest('hex'); | ||
return crypto.createHash('sha1').update(normalizeNewline(s)).digest('hex'); | ||
} | ||
|
||
export function createHashFromBuffers(ss: (string | Buffer)[]): string { | ||
const hash = crypto.createHash('sha1'); | ||
for (const s of ss) hash.update(normalizeNewline(s)); | ||
return hash.digest('hex'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.