|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
624 bytes
|
| Rev | Line | |
|---|
| [9af201e] | 1 | /*
|
|---|
| 2 | * MIT License http://opensource.org/licenses/MIT
|
|---|
| 3 | * Author: Ben Holloway @bholloway
|
|---|
| 4 | */
|
|---|
| 5 | 'use strict';
|
|---|
| 6 |
|
|---|
| 7 | const 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 |
|
|---|
| 24 | module.exports = fsUtils; |
|---|
Note:
See
TracBrowser
for help on using the repository browser.