UNPKG

1.28 kBJavaScriptView Raw
1"use strict";
2var __importStar = (this && this.__importStar) || function (mod) {
3 if (mod && mod.__esModule) return mod;
4 var result = {};
5 if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
6 result["default"] = mod;
7 return result;
8};
9Object.defineProperty(exports, "__esModule", { value: true });
10var fs = __importStar(require("fs"));
11function fileExistsSync(filePath) {
12 try {
13 fs.statSync(filePath);
14 }
15 catch (err) {
16 if (err.code === 'ENOENT') {
17 return false;
18 }
19 else {
20 throw err;
21 }
22 }
23 return true;
24}
25exports.fileExistsSync = fileExistsSync;
26// eslint-disable-next-line @typescript-eslint/no-explicit-any
27function throwIfIsInvalidSourceFileError(filepath, error) {
28 if (fileExistsSync(filepath) &&
29 // check the error type due to file system lag
30 !(error instanceof Error) &&
31 !(error.constructor.name === 'FatalError') &&
32 !(error.message && error.message.trim().startsWith('Invalid source file'))) {
33 // it's not because file doesn't exist - throw error
34 throw error;
35 }
36}
37exports.throwIfIsInvalidSourceFileError = throwIfIsInvalidSourceFileError;
38//# sourceMappingURL=FsHelper.js.map
\No newline at end of file