browserify / browserify/brfs

Handle failure for readFileSync

Open
#22 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
556
Forks
58
PR merge metrics
No merged PRs in 30d

Description

In node I can wrap a call to readFileSync in a synchronous try/catch:

```
var fs = require('fs');

try {
fs.readFileSync('./does/not/exist');
} catch (e) {
console.log('caught!');
}
```

and running it will write `caught!` but running through `browserify -t brfs` gives

```
events.js:72
throw er; // Unhandled 'error' event
^
Error: ENOENT, open './does/not/exist'
```

Is there a way that the same thing with brfs? I know that brfs processes the source statically, but I'm doing things like running the source through `envify` first and the fs call could fail and stop the build. Probably does so for the best, but I was wondering if there is a way to inline an empty string, undefined, etc.

Thanks substack!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.