source: trip-planner-front/node_modules/resolve-url-loader/lib/join-function/fs-utils.js@ 1ad8e64

Last change on this file since 1ad8e64 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 624 bytes
RevLine 
[6a3a178]1/*
2 * MIT License http://opensource.org/licenses/MIT
3 * Author: Ben Holloway @bholloway
4 */
5'use strict';
6
7const fsUtils = (fs) => {
8 // fs from enhanced-resolver doesn't include fs.existsSync so we need to use fs.statsSync instead
9 const withStats = (fn) => (absolutePath) => {
10 try {
11 return fn(fs.statSync(absolutePath));
12 } catch (e) {
13 return false;
14 }
15 };
16
17 return {
18 isFileSync: withStats((stats) => stats.isFile()),
19 isDirectorySync: withStats((stats) => stats.isDirectory()),
20 existsSync: withStats((stats) => stats.isFile() || stats.isDirectory())
21 };
22};
23
24module.exports = fsUtils;
Note: See TracBrowser for help on using the repository browser.