Skip to content

Commit

Permalink
fix: force gzip compression level to 9 (#71)
Browse files Browse the repository at this point in the history
this seems to avoid some platform related optimizations that result
in integrity mismatches due to the resulting compressed output not
being byte for byte identical.
  • Loading branch information
nlf authored Mar 22, 2021
1 parent fef420c commit 143a0b9
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
8 changes: 7 additions & 1 deletion lib/util/tar-create-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ const tarCreateOptions = manifest => ({
cwd: manifest._resolved,
prefix: 'package/',
portable: true,
gzip: true,
gzip: {
// forcing the level to 9 seems to avoid some
// platform specific optimizations that cause
// integrity mismatch errors due to differing
// end results after compression
level: 9
},

// ensure that package bins are always executable
// Note that npm-packlist is already filtering out
Expand Down
10 changes: 5 additions & 5 deletions tap-snapshots/test-dir.js-TAP.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
exports[`test/dir.js TAP basic > extract 1`] = `
Object {
"from": "file:test/fixtures/abbrev",
"integrity": "sha512-Ict4yhLfiPOkcX+yjBRSI2QUetKt+A08AXMyLeQbKGYg/OGI/1k47Hu9tWZOx1l4j+M1z07Zxt3IL41TmLkbDw==",
"integrity": "sha512-OCm45DHz7n9f1SEllmg3Bf1zBCzsiOYxMuodMZ5ux+HMoupmkzOftyOCKH07DhAcoyfUlos2VGmYkPHDxH92yg==",
"resolved": "\${CWD}/test/fixtures/abbrev",
}
`
Expand Down Expand Up @@ -176,15 +176,15 @@ Object {
exports[`test/dir.js TAP make bins executable > results of unpack 1`] = `
Object {
"from": "file:test/fixtures/bin-object",
"integrity": "sha512-rlE32nBV7XgKCm0I7YqAewyVPbaRJWUQMZUFLlngGK3imG+som3Hin7d/zPTikWg64tHIxb8VXeeq6u0IRRfmQ==",
"integrity": "sha512-hvYyDtqhAkxg/NF7eOjCpDcIs7ksaZjk9vrBkktxTJ0liITA/FsnEgmbP9l8h3rp+zN1QIvKAUvyTCYRpyCqZQ==",
"resolved": "\${CWD}/test/fixtures/bin-object",
}
`

exports[`test/dir.js TAP responds to foregroundScripts: true > extract 1`] = `
Object {
"from": "file:test/fixtures/prepare-script",
"integrity": "sha512-HTzPAt8wmXNchUdisnGDSCuUgrFee5v8F6GsLc5mQd29VXiNzv4PGz71jjLSIF1wWQSB+UjLTmSJSGznF/s/Lw==",
"integrity": "sha512-+bTA3RvkXgLMM1PIzfcwXkiiSYzCBHT6Jrqo8yt3owZtMhOnBomH1Dc0949tVurdyPk7WcrKitvsRnXRPCD4sQ==",
"resolved": "\${CWD}/test/fixtures/prepare-script",
}
`
Expand Down Expand Up @@ -250,7 +250,7 @@ Object {
exports[`test/dir.js TAP responds to foregroundScripts: true and log:{level: silent} > extract 1`] = `
Object {
"from": "file:test/fixtures/prepare-script",
"integrity": "sha512-HTzPAt8wmXNchUdisnGDSCuUgrFee5v8F6GsLc5mQd29VXiNzv4PGz71jjLSIF1wWQSB+UjLTmSJSGznF/s/Lw==",
"integrity": "sha512-+bTA3RvkXgLMM1PIzfcwXkiiSYzCBHT6Jrqo8yt3owZtMhOnBomH1Dc0949tVurdyPk7WcrKitvsRnXRPCD4sQ==",
"resolved": "\${CWD}/test/fixtures/prepare-script",
}
`
Expand Down Expand Up @@ -316,7 +316,7 @@ Object {
exports[`test/dir.js TAP with prepare script > extract 1`] = `
Object {
"from": "file:test/fixtures/prepare-script",
"integrity": "sha512-HTzPAt8wmXNchUdisnGDSCuUgrFee5v8F6GsLc5mQd29VXiNzv4PGz71jjLSIF1wWQSB+UjLTmSJSGznF/s/Lw==",
"integrity": "sha512-+bTA3RvkXgLMM1PIzfcwXkiiSYzCBHT6Jrqo8yt3owZtMhOnBomH1Dc0949tVurdyPk7WcrKitvsRnXRPCD4sQ==",
"resolved": "\${CWD}/test/fixtures/prepare-script",
}
`
Expand Down
4 changes: 3 additions & 1 deletion test/dir.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ t.test('exposes tarCreateOptions method', async t => {
cwd: '/home/foo',
prefix: 'package/',
portable: true,
gzip: true,
gzip: {
level: 9
},
mtime: new Date('1985-10-26T08:15:00.000Z'),
},
'should return standard options'
Expand Down
4 changes: 3 additions & 1 deletion test/util/tar-create-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ t.match(
cwd: '/home/foo',
prefix: 'package/',
portable: true,
gzip: true,
gzip: {
level: 9
},
mtime: new Date('1985-10-26T08:15:00.000Z'),
},
'should return standard options'
Expand Down

0 comments on commit 143a0b9

Please sign in to comment.