Skip to content

Commit 48ba123

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

2 files changed

Lines changed: 32 additions & 10 deletions

File tree

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: 30 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,41 @@ 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(dir: string, extension: string): Promise<string[]> {
181+
const results: string[] = [];
182+
183+
async function searchRecursively(currentDir: string, relativePath = ''): Promise<void> {
184+
const entries = await fs.readdir(currentDir, { withFileTypes: true });
185+
186+
for (const entry of entries) {
187+
const fullPath = path.join(currentDir, entry.name);
188+
const relPath = path.join(relativePath, entry.name);
189+
190+
if (entry.isDirectory()) {
191+
await searchRecursively(fullPath, relPath);
192+
} else if (entry.isFile() && fullPath.endsWith(`.${extension}`)) {
193+
results.push(relPath);
194+
}
195+
}
196+
}
197+
198+
await searchRecursively(dir);
199+
return results;
200+
}
201+
177202
async function getAppPathAsync(
178203
outputDir: string,
179204
applicationExtension: string,
180205
): Promise<string> {
181206
logger.startSpinner(`Locating ${applicationExtension} file`);
182-
const appFilePaths = await glob(`./**/*.${applicationExtension}`, {
183-
cwd: outputDir,
184-
onlyFiles: false,
185-
});
207+
const appFilePaths = await findFilesByExtension(outputDir, applicationExtension);
186208
if (appFilePaths.length === 0) {
187209
logger.failSpinner("Search failed");
188210
throw Error("Did not find any installable apps inside tarball.");

0 commit comments

Comments
 (0)