Skip to content

Commit f0e86c2

Browse files
authored
fix: temporarially pin to specific binary version (#116)
* fix: temporarially pin to specific binary version * bun.lock
1 parent 52f93c3 commit f0e86c2

File tree

4 files changed

+46
-23
lines changed

4 files changed

+46
-23
lines changed

src/download.ts

+27-18
Original file line numberDiff line numberDiff line change
@@ -38,28 +38,37 @@ export async function getDenoDownloadUrl(
3838
}
3939

4040
const name = FILENAMES[key];
41-
42-
const url = canary ? DENO_CANARY_INFO_URL : DENO_RELEASE_INFO_URL;
43-
const res = await fetch(url);
44-
if (!res.ok) {
45-
await res.body?.cancel();
46-
throw new Error(
47-
`${res.status}: Unable to retrieve ${
48-
canary ? "canary" : "release"
49-
} version information from ${url}.`,
50-
);
51-
}
52-
const version = (await res.text()).trim();
53-
5441
const filename = name + ".zip";
42+
5543
return {
56-
canary,
57-
url: canary
58-
? `https://dl.deno.land/canary/${decodeURI(version)}/${filename}`
59-
: `https://dl.deno.land/release/${decodeURI(version)}/${filename}`,
44+
canary: false,
45+
url:
46+
`https://dl.deno.land/canary/c38dbe500b0a5815f4b07d4a6b696c5fdf622dc0/${filename}`,
6047
filename,
61-
version: version,
48+
version: "c38dbe500b0a5815f4b07d4a6b696c5fdf622dc0",
6249
};
50+
51+
// TEMPORARIALLY FORCE USE OF VERSION c38dbe500b0a5815f4b07d4a6b696c5fdf622dc0
52+
// const url = canary ? DENO_CANARY_INFO_URL : DENO_RELEASE_INFO_URL;
53+
// const res = await fetch(url);
54+
// if (!res.ok) {
55+
// await res.body?.cancel();
56+
// throw new Error(
57+
// `${res.status}: Unable to retrieve ${
58+
// canary ? "canary" : "release"
59+
// } version information from ${url}.`,
60+
// );
61+
// }
62+
// const version = (await res.text()).trim();
63+
64+
// return {
65+
// canary,
66+
// url: canary
67+
// ? `https://dl.deno.land/canary/${decodeURI(version)}/${filename}`
68+
// : `https://dl.deno.land/release/${decodeURI(version)}/${filename}`,
69+
// filename,
70+
// version: version,
71+
// };
6372
}
6473

6574
export async function downloadDeno(

src/utils.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,13 @@ export async function findProjectDir(
118118
// prefer bun.lockb over yarn.lock
119119
// In some cases, both bun.lockb and yarn.lock can exist in the same project.
120120
// https://bun.sh/docs/install/lockfile
121-
const bunLockfile = path.join(dir, "bun.lockb");
121+
const bunbLockfile = path.join(dir, "bun.lockb");
122+
if (await fileExists(bunbLockfile)) {
123+
logDebug(`Detected bun from lockfile ${bunbLockfile}`);
124+
result.pkgManagerName = "bun";
125+
return result;
126+
}
127+
const bunLockfile = path.join(dir, "bun.lock");
122128
if (await fileExists(bunLockfile)) {
123129
logDebug(`Detected bun from lockfile ${bunLockfile}`);
124130
result.pkgManagerName = "bun";

test/commands.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ describe("install", () => {
277277
["i", "--bun", "--save-dev", "@std/[email protected]"],
278278
async (dir) => {
279279
assert.ok(
280-
await isFile(path.join(dir, "bun.lockb")),
280+
await isFile(path.join(dir, "bun.lock")),
281281
"bun lockfile not created",
282282
);
283283
const pkgJson = await readJson<PkgJson>(
@@ -333,7 +333,7 @@ describe("install", () => {
333333
["i", "--bun", "--save-optional", "@std/[email protected]"],
334334
async (dir) => {
335335
assert.ok(
336-
await isFile(path.join(dir, "bun.lockb")),
336+
await isFile(path.join(dir, "bun.lock")),
337337
"bun lockfile not created",
338338
);
339339
const pkgJson = await readJson<PkgJson>(
@@ -440,7 +440,7 @@ describe("install", () => {
440440
["i", "--bun", "@std/[email protected]"],
441441
async (dir) => {
442442
assert.ok(
443-
await isFile(path.join(dir, "bun.lockb")),
443+
await isFile(path.join(dir, "bun.lock")),
444444
"bun lockfile not created",
445445
);
446446

@@ -584,7 +584,7 @@ describe("install", () => {
584584
["i", "@std/[email protected]"],
585585
async (dir) => {
586586
assert.ok(
587-
await isFile(path.join(dir, "bun.lockb")),
587+
await isFile(path.join(dir, "bun.lock")),
588588
"bun lockfile not created",
589589
);
590590
},

test/utils.test.ts

+8
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ describe("findProjectDir", () => {
4242
});
4343
});
4444

45+
it("should return bun if bun.lock is found", async () => {
46+
await runInTempDir(async (tempDir) => {
47+
await writeTextFile(path.join(tempDir, "bun.lock"), "");
48+
const result = await findProjectDir(tempDir);
49+
assert.strictEqual(result.pkgManagerName, "bun");
50+
});
51+
});
52+
4553
it("should return bun if bun.lockb and yarn.lock are found", async () => {
4654
// bun allow to save bun.lockb and yarn.lock
4755
// https://bun.sh/docs/install/lockfile

0 commit comments

Comments
 (0)