Skip to content

Commit 8071bbe

Browse files
committed
chore: update dependencies and add file search utility
1 parent 79569cc commit 8071bbe

File tree

2 files changed

+41
-10
lines changed

2 files changed

+41
-10
lines changed

bun.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/download.ts

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ import * as spawnAsyncModule from "@expo/spawn-async";
99

1010
const spawnAsync = spawnAsyncModule.default || spawnAsyncModule;
1111

12-
import * as globModule from "fast-glob";
13-
14-
const glob = globModule.default || globModule;
15-
1612
import * as path from "node:path";
1713
import { pipeline } from "node:stream/promises";
1814
import * as fs from "fs-extra";
@@ -174,15 +170,50 @@ export async function extractAppFromLocalArchiveAsync(
174170
);
175171
}
176172

173+
/**
174+
* Recursively finds files with a specific extension
175+
*
176+
* @param {string} dir - Directory to search in
177+
* @param {string} extension - File extension to search for
178+
* @returns {Promise<string[]>} - Array of relative file paths
179+
*/
180+
async function findFilesByExtension(
181+
dir: string,
182+
extension: string,
183+
): Promise<string[]> {
184+
const results: string[] = [];
185+
186+
async function searchRecursively(
187+
currentDir: string,
188+
relativePath = "",
189+
): Promise<void> {
190+
const entries = await fs.readdir(currentDir, { withFileTypes: true });
191+
192+
for (const entry of entries) {
193+
const fullPath = path.join(currentDir, entry.name);
194+
const relPath = path.join(relativePath, entry.name);
195+
196+
if (entry.isDirectory()) {
197+
await searchRecursively(fullPath, relPath);
198+
} else if (entry.isFile() && fullPath.endsWith(`.${extension}`)) {
199+
results.push(relPath);
200+
}
201+
}
202+
}
203+
204+
await searchRecursively(dir);
205+
return results;
206+
}
207+
177208
async function getAppPathAsync(
178209
outputDir: string,
179210
applicationExtension: string,
180211
): Promise<string> {
181212
logger.startSpinner(`Locating ${applicationExtension} file`);
182-
const appFilePaths = await glob(`./**/*.${applicationExtension}`, {
183-
cwd: outputDir,
184-
onlyFiles: false,
185-
});
213+
const appFilePaths = await findFilesByExtension(
214+
outputDir,
215+
applicationExtension,
216+
);
186217
if (appFilePaths.length === 0) {
187218
logger.failSpinner("Search failed");
188219
throw Error("Did not find any installable apps inside tarball.");

0 commit comments

Comments
 (0)