Skip to content

Commit

Permalink
fix: add workspace.fs.stat error handling when files are missing (#259
Browse files Browse the repository at this point in the history
)
  • Loading branch information
byCedric committed Mar 13, 2024
1 parent ee37364 commit a5c6199
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/expo/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,14 @@ export class ExpoProjectCache extends MapCacheProvider<ExpoProject> {

const packagePath = vscode.Uri.joinPath(projectPath, 'package.json');

// Ensure the project has a `package.json` file
const packageInfo = await vscode.workspace.fs.stat(packagePath);
if (packageInfo.type !== vscode.FileType.File) {
try {
// Ensure the project has a `package.json` file
const packageInfo = await vscode.workspace.fs.stat(packagePath);
if (packageInfo.type !== vscode.FileType.File) {
return undefined;
}
} catch (error) {
log('Failed to load Expo project "package.json": %s', error.message);
return undefined;
}

Expand All @@ -92,11 +97,15 @@ export class ExpoProjectCache extends MapCacheProvider<ExpoProject> {

// Load the `app.json` or `app.config.json` file, if available
for (const appFileName of ['app.json', 'app.config.json']) {
const filePath = vscode.Uri.joinPath(projectPath, appFileName);
const fileStat = await vscode.workspace.fs.stat(filePath);
if (fileStat.type === vscode.FileType.File) {
project.setManifest(await readWorkspaceFile(filePath));
break;
try {
const filePath = vscode.Uri.joinPath(projectPath, appFileName);
const fileStat = await vscode.workspace.fs.stat(filePath);
if (fileStat.type === vscode.FileType.File) {
project.setManifest(await readWorkspaceFile(filePath));
break;
}
} catch (error) {
log('Failed to load Expo project "%s": %s', appFileName, error.message);
}
}

Expand Down

0 comments on commit a5c6199

Please sign in to comment.