Skip to content

Commit 950e0b2

Browse files
committed
fix runIntegrationTest
1 parent 2fbccfa commit 950e0b2

File tree

3 files changed

+36
-27
lines changed

3 files changed

+36
-27
lines changed

integration-tests/apply-multiple-patches/__snapshots__/apply-multiple-patches.test.ts.snap

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,24 @@ END SNAPSHOT"
1313
exports[`Test apply-multiple-patches: 01: patch-package stores a state file to list the patches that have been applied 1`] = `
1414
"SNAPSHOT: patch-package stores a state file to list the patches that have been applied
1515
{
16-
\\"version\\": 0,
17-
\\"patches\\": [
18-
{
19-
\\"patchFilename\\": \\"left-pad+1.3.0+001+hello.patch\\",
20-
\\"didApply\\": true,
21-
\\"patchContentHash\\": \\"404c604ed830db6a0605f86cb9165ced136848f70986b23bf877bcf38968c1c9\\"
22-
},
23-
{
24-
\\"patchFilename\\": \\"left-pad+1.3.0+002+world.patch\\",
25-
\\"didApply\\": true,
26-
\\"patchContentHash\\": \\"f2859c7193de8d9578bdde7e226de516adc8d972d6e76997cbe1f41b1a535359\\"
27-
},
28-
{
29-
\\"patchFilename\\": \\"left-pad+1.3.0+003+goodbye.patch\\",
30-
\\"didApply\\": true,
31-
\\"patchContentHash\\": \\"946d4e578decc1e475ca9b0de07353791969312fd2bf5d9cfc5182b86d9804ad\\"
32-
}
33-
]
16+
\\"patches\\": [
17+
{
18+
\\"didApply\\": true,
19+
\\"patchContentHash\\": \\"404c604ed830db6a0605f86cb9165ced136848f70986b23bf877bcf38968c1c9\\",
20+
\\"patchFilename\\": \\"left-pad+1.3.0+001+hello.patch\\"
21+
},
22+
{
23+
\\"didApply\\": true,
24+
\\"patchContentHash\\": \\"f2859c7193de8d9578bdde7e226de516adc8d972d6e76997cbe1f41b1a535359\\",
25+
\\"patchFilename\\": \\"left-pad+1.3.0+003+world.patch\\"
26+
},
27+
{
28+
\\"didApply\\": true,
29+
\\"patchContentHash\\": \\"946d4e578decc1e475ca9b0de07353791969312fd2bf5d9cfc5182b86d9804ad\\",
30+
\\"patchFilename\\": \\"left-pad+1.3.0+004+goodbye.patch\\"
31+
}
32+
],
33+
\\"version\\": 0
3434
}END SNAPSHOT"
3535
`;
3636

@@ -45,14 +45,14 @@ END SNAPSHOT"
4545
exports[`Test apply-multiple-patches: 03: patch-package stores a state file of only the first patch if there was an error 1`] = `
4646
"SNAPSHOT: patch-package stores a state file of only the first patch if there was an error
4747
{
48-
\\"patches\\": [
49-
{
50-
\\"didApply\\": true,
51-
\\"patchContentHash\\": \\"404c604ed830db6a0605f86cb9165ced136848f70986b23bf877bcf38968c1c9\\",
52-
\\"patchFilename\\": \\"left-pad+1.3.0+001+hello.patch\\"
53-
}
54-
],
55-
\\"version\\": 0
48+
\\"patches\\": [
49+
{
50+
\\"didApply\\": true,
51+
\\"patchContentHash\\": \\"404c604ed830db6a0605f86cb9165ced136848f70986b23bf877bcf38968c1c9\\",
52+
\\"patchFilename\\": \\"left-pad+1.3.0+001+hello.patch\\"
53+
}
54+
],
55+
\\"version\\": 0
5656
}END SNAPSHOT"
5757
`;
5858

integration-tests/runIntegrationTest.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { join, resolve } from "../src/path"
33
import * as tmp from "tmp"
44
import { spawnSafeSync } from "../src/spawnSafe"
55
import { resolveRelativeFileDependencies } from "../src/resolveRelativeFileDependencies"
6+
import rimraf from "rimraf"
67

78
export const patchPackageTarballPath = resolve(
89
fs
@@ -23,6 +24,9 @@ export function runIntegrationTest({
2324
recursive: true,
2425
})
2526

27+
// remove node_modules folder when running locally, to avoid leaking state from source dir
28+
rimraf.sync(join(tmpDir.name, "node_modules"))
29+
2630
const packageJson = require(join(tmpDir.name, "package.json"))
2731
packageJson.dependencies = resolveRelativeFileDependencies(
2832
join(__dirname, projectName),

src/stateFile.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,12 @@ export function savePatchApplicationState(
3737
) {
3838
const fileName = join(packageDetails.path, STATE_FILE_NAME)
3939

40-
writeFileSync(fileName, stringify({ version, patches }, { space: 2 }), "utf8")
40+
const state: PatchApplicationState = {
41+
patches,
42+
version,
43+
}
44+
45+
writeFileSync(fileName, stringify(state, { space: 4 }), "utf8")
4146
}
4247

4348
export function clearPatchApplicationState(packageDetails: PackageDetails) {

0 commit comments

Comments
 (0)