UNPKG

920 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const fs = require("fs");
4function fileExistsSync(filePath) {
5 try {
6 fs.statSync(filePath);
7 }
8 catch (err) {
9 if (err.code === 'ENOENT') {
10 return false;
11 }
12 else {
13 throw err;
14 }
15 }
16 return true;
17}
18exports.fileExistsSync = fileExistsSync;
19function throwIfIsInvalidSourceFileError(filepath, error) {
20 if (fileExistsSync(filepath) &&
21 // check the error type due to file system lag
22 !(error instanceof Error) &&
23 !(error.constructor.name === 'FatalError') &&
24 !(error.message && error.message.trim().startsWith('Invalid source file'))) {
25 // it's not because file doesn't exist - throw error
26 throw error;
27 }
28}
29exports.throwIfIsInvalidSourceFileError = throwIfIsInvalidSourceFileError;
30//# sourceMappingURL=FsHelper.js.map
\No newline at end of file