-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
205 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
'use strict' | ||
|
||
module.exports = { | ||
sha1ToHexChecksum (sha1) { | ||
return sha1 | ||
? Buffer.from(sha1, 'base64').toString('hex') | ||
: undefined | ||
}, | ||
hexChecksumToSha1 (hexChecksum) { | ||
const decoded = Buffer.from(hexChecksum, 'hex').toString('base64') | ||
|
||
return decoded.length === 28 | ||
? 'sha1-' + decoded | ||
: undefined | ||
}, | ||
|
||
// NOTE npm lockfile may handle several hashes in a single field | ||
formatNpmIntegrity (...integrities) { | ||
return Object.keys(integrities.reduce((memo, str) => { | ||
str && str.split(' ').forEach((integrity) => { | ||
memo[integrity] = integrity | ||
}) | ||
|
||
return memo | ||
}, {})).join(' ') || undefined | ||
}, | ||
parseIntegrity (integrity) { | ||
if (!integrity) { | ||
return {} | ||
} | ||
|
||
const chunks = integrity.split(' ') | ||
|
||
return chunks.reduce((memo, hash) => { | ||
const key = /^sha1-/.test(hash) ? 'sha1' : 'sha512' | ||
const value = hash.slice(key.length + 1) | ||
|
||
memo[key] = value | ||
|
||
return memo | ||
}, {}) | ||
}, | ||
formatYarnIntegrity (hash) { | ||
if (!hash) { | ||
return undefined | ||
} | ||
|
||
return hash.length === 28 | ||
? 'sha1-' + hash | ||
: 'sha512-' + hash | ||
} | ||
} |
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,3 +1,5 @@ | ||
'use strict' | ||
|
||
const glob = require('bash-glob') | ||
const { sep, resolve } = require('path') | ||
|
||
|
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"name": "integrity-mix", | ||
"version": "1.0.0", | ||
"lockfileVersion": 1, | ||
"requires": true, | ||
"dependencies": { | ||
"@semantic-release/npm": { | ||
"version": "7.0.5", | ||
"resolved": "https://registry.npmjs.org/@semantic-release/npm/-/npm-7.0.5.tgz", | ||
"integrity": "sha1-YcRWkau4Y/aTnMpqrJWNPCJQhjI= sha512-D+oEmsx9aHE1q806NFQwSC9KdBO8ri/VO99eEz0wWbX2jyLqVyWr7t0IjKC8aSnkkQswg/4KN/ZjfF6iz1XOpw==" | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. | ||
# yarn lockfile v1 | ||
|
||
|
||
"@semantic-release/npm@^7.0.0": | ||
version "7.0.5" | ||
resolved "https://registry.npmjs.org/@semantic-release/npm/-/npm-7.0.5.tgz#61c45691abb863f6939cca6aac958d3c22508632" | ||
integrity sha512-D+oEmsx9aHE1q806NFQwSC9KdBO8ri/VO99eEz0wWbX2jyLqVyWr7t0IjKC8aSnkkQswg/4KN/ZjfF6iz1XOpw== |
12 changes: 12 additions & 0 deletions
12
test/fixtures/integrity-mix/node_modules/@semantic-release/npm/package.json
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "integrity-mix", | ||
"version": "1.0.0", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@semantic-release/npm": "^7.0.0" | ||
} | ||
} |
Oops, something went wrong.