Commit 349d2c4
committed
[Fix] Panic when using npm start on OSX - fresh dev setup.
Panic occurs when the path ~/Library/Preferences/Soundnode does not exist (ie a fresh dev setup) since `getUserConfig()` uses `fs.statSync(..)`, which throws an exception instead of returning an error if the directory does not exist.
If the directory mention above does exist, all is fine. When it doesn't, such as on a fresh dev setup, every time you run 'npm start' you get a panic and the app crashes.
My solution to this is to wrap `fs.statSync(..)` in a try catch and problem solved.
Furthermore I added in a guard which checks the type of `userConfigPath`. The reason for this guard is so we can throw a useful exception rather than a generic undefined or null exception.1 parent e190610 commit 349d2c4
1 file changed
Lines changed: 17 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
41 | 46 | | |
42 | 47 | | |
43 | | - | |
44 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
45 | 60 | | |
46 | | - | |
47 | 61 | | |
48 | 62 | | |
49 | 63 | | |
| |||
0 commit comments