| 25 | }; |
| 26 | |
| 27 | const fetchLocalFile = src => |
| 28 | new Promise((resolve, reject) => { |
| 29 | try { |
| 30 | if (BROWSER) { |
| 31 | reject(new Error('Cannot fetch local file in this environemnt')); |
| 32 | return; |
| 33 | } |
| 34 | const absolutePath = getAbsoluteLocalPath(src); |
| 35 | if (!absolutePath) { |
| 36 | reject(new Error(`Cannot fetch non-local path: ${src}`)); |
| 37 | return; |
| 38 | } |
| 39 | fs.readFile(absolutePath, (err, data) => |
| 40 | err ? reject(err) : resolve(data), |
| 41 | ); |
| 42 | } catch (err) { |
| 43 | reject(err); |
| 44 | } |
| 45 | }); |
| 46 | |
| 47 | const fetchRemoteFile = async (uri, options) => { |
| 48 | const response = await fetch(uri, options); |
no test coverage detected