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
16
dist/setup.js
vendored
16
dist/setup.js
vendored
@ -74,14 +74,18 @@ function getDownloadUrl(options) {
|
||||
}
|
||||
async function extractBun(path) {
|
||||
for (const entry of await readdir(path, { withFileTypes: true })) {
|
||||
const entryPath = join(path, entry.name);
|
||||
action.debug(`Looking: ${entryPath}`);
|
||||
if (entry.name === "bun" && entry.isFile()) {
|
||||
action.debug(`Found: ${entryPath}`);
|
||||
const { name } = entry;
|
||||
const entryPath = join(path, name);
|
||||
if (entry.isFile()) {
|
||||
if (name === "bun") {
|
||||
return entryPath;
|
||||
}
|
||||
if (entry.name.startsWith("bun") && entry.isDirectory()) {
|
||||
action.debug(`Continue looking: ${entryPath}`);
|
||||
if (/^bun.*\.zip/.test(name)) {
|
||||
const extractedPath = await extractZip(entryPath);
|
||||
return extractBun(extractedPath);
|
||||
}
|
||||
}
|
||||
if (/^bun/.test(name) && entry.isDirectory()) {
|
||||
return extractBun(entryPath);
|
||||
}
|
||||
}
|
||||
|
21
src/setup.ts
21
src/setup.ts
@ -39,10 +39,7 @@ export default async (options?: {
|
||||
if (!cacheHit) {
|
||||
action.info(`Downloading a new version of Bun: ${url}`);
|
||||
const zipPath = await downloadTool(url);
|
||||
let extractedPath = await extractZip(zipPath);
|
||||
if (extractedPath.endsWith(".zip")) {
|
||||
extractedPath = await extractZip(extractedPath);
|
||||
}
|
||||
const extractedPath = await extractZip(zipPath);
|
||||
const exePath = await extractBun(extractedPath);
|
||||
await mv(exePath, path);
|
||||
version = await verifyBun(path);
|
||||
@ -101,14 +98,18 @@ function getDownloadUrl(options?: {
|
||||
|
||||
async function extractBun(path: string): Promise<string> {
|
||||
for (const entry of await readdir(path, { withFileTypes: true })) {
|
||||
const entryPath = join(path, entry.name);
|
||||
action.debug(`Looking: ${entryPath}`);
|
||||
if (entry.name === "bun" && entry.isFile()) {
|
||||
action.debug(`Found: ${entryPath}`);
|
||||
const { name } = entry;
|
||||
const entryPath = join(path, name);
|
||||
if (entry.isFile()) {
|
||||
if (name === "bun") {
|
||||
return entryPath;
|
||||
}
|
||||
if (entry.name.startsWith("bun") && entry.isDirectory()) {
|
||||
action.debug(`Continue looking: ${entryPath}`);
|
||||
if (/^bun.*\.zip/.test(name)) {
|
||||
const extractedPath = await extractZip(entryPath);
|
||||
return extractBun(extractedPath);
|
||||
}
|
||||
}
|
||||
if (/^bun/.test(name) && entry.isDirectory()) {
|
||||
return extractBun(entryPath);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user