-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
1 parent
2cba070
commit a62a62f
Showing
4 changed files
with
174 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -351,6 +351,58 @@ index c8950c17b265104bcf27f8c345df1a1b13a78950..7ce57ab96400ab0ff4fac7e06f6e02c2 | |
} | ||
}); | ||
|
||
describe("should work when patches are removed", async () => { | ||
for (const [version, patchVersion_] of versions) { | ||
const patchFilename = filepathEscape(`is-even@${version}.patch`); | ||
const patchVersion = patchVersion_ ?? version; | ||
test(version, async () => { | ||
const filedir = tempDirWithFiles("patch1", { | ||
"package.json": JSON.stringify({ | ||
"name": "bun-patch-test", | ||
"module": "index.ts", | ||
"type": "module", | ||
"patchedDependencies": { | ||
[`is-even@${patchVersion}`]: `patches/${patchFilename}`, | ||
}, | ||
"dependencies": { | ||
"is-even": version, | ||
}, | ||
}), | ||
patches: { | ||
[patchFilename]: is_even_patch2, | ||
}, | ||
"index.ts": /* ts */ `import isEven from 'is-even'; isEven(2); console.log('lol')`, | ||
}); | ||
|
||
console.log("FILEDIR", filedir); | ||
|
||
await $`${bunExe()} i`.env(bunEnv).cwd(filedir); | ||
throw new Error("woopsie!"); | ||
|
||
await $`echo ${JSON.stringify({ | ||
"name": "bun-patch-test", | ||
"module": "index.ts", | ||
"type": "module", | ||
"patchedDependencies": { | ||
[`[email protected]`]: `patches/[email protected]`, | ||
}, | ||
"dependencies": { | ||
"is-even": version, | ||
}, | ||
})} > package.json` | ||
.env(bunEnv) | ||
.cwd(filedir); | ||
|
||
await $`echo ${is_odd_patch2} > patches/[email protected]; ${bunExe()} i`.env(bunEnv).cwd(filedir); | ||
|
||
const { stdout, stderr } = await $`${bunExe()} run index.ts`.env(bunEnv).cwd(filedir); | ||
expect(stderr.toString()).toBe(""); | ||
expect(stdout.toString()).toContain("Hi from isOdd!\n"); | ||
expect(stdout.toString()).not.toContain("lmao\n"); | ||
}); | ||
} | ||
}); | ||
|
||
it("should update a transitive dependency when the patchfile changes", async () => { | ||
$.throws(true); | ||
const filedir = tempDirWithFiles("patch1", { | ||
|
@@ -379,4 +431,56 @@ index c8950c17b265104bcf27f8c345df1a1b13a78950..7ce57ab96400ab0ff4fac7e06f6e02c2 | |
expect(stderr.toString()).toBe(""); | ||
expect(stdout.toString()).toContain("lmao\n"); | ||
}); | ||
|
||
it("should update a scoped package", async () => { | ||
const patchfile = /* patch */ `diff --git a/private/var/folders/wy/3969rv2x63g63jf8jwlcb2x40000gn/T/.b7f7d77b9ffdd3ee-00000000.tmp/index.js b/index.js | ||
new file mode 100644 | ||
index 0000000000000000000000000000000000000000..6edc0598a84632c41d9c770cfbbad7d99e2ab624 | ||
--- /dev/null | ||
+++ b/index.js | ||
@@ -0,0 +1,4 @@ | ||
+ | ||
+module.exports = () => { | ||
+ return 'PATCHED!' | ||
+} | ||
diff --git a/package.json b/package.json | ||
index aa7c7012cda790676032d1b01d78c0b69ec06360..6048e7cb462b3f9f6ac4dc21aacf9a09397cd4be 100644 | ||
--- a/package.json | ||
+++ b/package.json | ||
@@ -2,7 +2,7 @@ | ||
"name": "@zackradisic/hls-dl", | ||
"version": "0.0.1", | ||
"description": "", | ||
- "main": "dist/hls-dl.commonjs2.js", | ||
+ "main": "./index.js", | ||
"dependencies": { | ||
"m3u8-parser": "^4.5.0", | ||
"typescript": "^4.0.5" | ||
`; | ||
|
||
$.throws(true); | ||
const filedir = tempDirWithFiles("patch1", { | ||
"package.json": JSON.stringify({ | ||
"name": "bun-patch-test", | ||
"module": "index.ts", | ||
"type": "module", | ||
"patchedDependencies": { | ||
"@zackradisic/[email protected]": "patches/thepatch.patch", | ||
}, | ||
"dependencies": { | ||
"@zackradisic/hls-dl": "0.0.1", | ||
}, | ||
}), | ||
patches: { | ||
["thepatch.patch"]: patchfile, | ||
}, | ||
"index.ts": /* ts */ `import hlsDl from '@zackradisic/hls-dl'; console.log(hlsDl())`, | ||
}); | ||
|
||
await $`${bunExe()} i`.env(bunEnv).cwd(filedir); | ||
|
||
const { stdout, stderr } = await $`${bunExe()} run index.ts`.env(bunEnv).cwd(filedir); | ||
expect(stderr.toString()).toBe(""); | ||
expect(stdout.toString()).toContain("PATCHED!\n"); | ||
}); | ||
}); |