mirror of
https://github.com/oven-sh/setup-bun.git
synced 2025-04-02 01:30:17 +08:00
Actually fix double zip issue
This commit is contained in:
parent
a730821cf4
commit
15050a7632
18
dist/setup.js
vendored
18
dist/setup.js
vendored
@ -74,14 +74,18 @@ function getDownloadUrl(options) {
|
|||||||
}
|
}
|
||||||
async function extractBun(path) {
|
async function extractBun(path) {
|
||||||
for (const entry of await readdir(path, { withFileTypes: true })) {
|
for (const entry of await readdir(path, { withFileTypes: true })) {
|
||||||
const entryPath = join(path, entry.name);
|
const { name } = entry;
|
||||||
action.debug(`Looking: ${entryPath}`);
|
const entryPath = join(path, name);
|
||||||
if (entry.name === "bun" && entry.isFile()) {
|
if (entry.isFile()) {
|
||||||
action.debug(`Found: ${entryPath}`);
|
if (name === "bun") {
|
||||||
return entryPath;
|
return entryPath;
|
||||||
|
}
|
||||||
|
if (/^bun.*\.zip/.test(name)) {
|
||||||
|
const extractedPath = await extractZip(entryPath);
|
||||||
|
return extractBun(extractedPath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (entry.name.startsWith("bun") && entry.isDirectory()) {
|
if (/^bun/.test(name) && entry.isDirectory()) {
|
||||||
action.debug(`Continue looking: ${entryPath}`);
|
|
||||||
return extractBun(entryPath);
|
return extractBun(entryPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
23
src/setup.ts
23
src/setup.ts
@ -39,10 +39,7 @@ export default async (options?: {
|
|||||||
if (!cacheHit) {
|
if (!cacheHit) {
|
||||||
action.info(`Downloading a new version of Bun: ${url}`);
|
action.info(`Downloading a new version of Bun: ${url}`);
|
||||||
const zipPath = await downloadTool(url);
|
const zipPath = await downloadTool(url);
|
||||||
let extractedPath = await extractZip(zipPath);
|
const extractedPath = await extractZip(zipPath);
|
||||||
if (extractedPath.endsWith(".zip")) {
|
|
||||||
extractedPath = await extractZip(extractedPath);
|
|
||||||
}
|
|
||||||
const exePath = await extractBun(extractedPath);
|
const exePath = await extractBun(extractedPath);
|
||||||
await mv(exePath, path);
|
await mv(exePath, path);
|
||||||
version = await verifyBun(path);
|
version = await verifyBun(path);
|
||||||
@ -101,14 +98,18 @@ function getDownloadUrl(options?: {
|
|||||||
|
|
||||||
async function extractBun(path: string): Promise<string> {
|
async function extractBun(path: string): Promise<string> {
|
||||||
for (const entry of await readdir(path, { withFileTypes: true })) {
|
for (const entry of await readdir(path, { withFileTypes: true })) {
|
||||||
const entryPath = join(path, entry.name);
|
const { name } = entry;
|
||||||
action.debug(`Looking: ${entryPath}`);
|
const entryPath = join(path, name);
|
||||||
if (entry.name === "bun" && entry.isFile()) {
|
if (entry.isFile()) {
|
||||||
action.debug(`Found: ${entryPath}`);
|
if (name === "bun") {
|
||||||
return entryPath;
|
return entryPath;
|
||||||
|
}
|
||||||
|
if (/^bun.*\.zip/.test(name)) {
|
||||||
|
const extractedPath = await extractZip(entryPath);
|
||||||
|
return extractBun(extractedPath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (entry.name.startsWith("bun") && entry.isDirectory()) {
|
if (/^bun/.test(name) && entry.isDirectory()) {
|
||||||
action.debug(`Continue looking: ${entryPath}`);
|
|
||||||
return extractBun(entryPath);
|
return extractBun(entryPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user