@file-services/node
Advanced tools
Comparing version 5.4.3 to 5.7.0
@@ -13,2 +13,4 @@ "use strict"; | ||
const watch_service_js_1 = require("./watch-service.js"); | ||
const nodeMajor = parseInt(process.versions.node, 10); | ||
const needsStatPolyfill = nodeMajor < 14; | ||
const caseSensitive = !fs_1.default.existsSync(__filename.toUpperCase()); | ||
@@ -27,2 +29,4 @@ function createNodeFs(options) { | ||
...fs_1.default, | ||
statSync: needsStatPolyfill ? statSync : fs_1.default.statSync, | ||
lstatSync: needsStatPolyfill ? lstatSync : fs_1.default.lstatSync, | ||
promises: { | ||
@@ -35,2 +39,32 @@ ...fs_1.default.promises, | ||
exports.createBaseNodeFs = createBaseNodeFs; | ||
function statSync(path, options) { | ||
var _a; | ||
try { | ||
return fs_1.default.statSync(path, options); | ||
} | ||
catch (e) { | ||
const throwIfNoEntry = (_a = options === null || options === void 0 ? void 0 : options.throwIfNoEntry) !== null && _a !== void 0 ? _a : true; | ||
if (throwIfNoEntry) { | ||
throw e; | ||
} | ||
else { | ||
return undefined; | ||
} | ||
} | ||
} | ||
function lstatSync(path, options) { | ||
var _a; | ||
try { | ||
return fs_1.default.lstatSync(path, options); | ||
} | ||
catch (e) { | ||
const throwIfNoEntry = (_a = options === null || options === void 0 ? void 0 : options.throwIfNoEntry) !== null && _a !== void 0 ? _a : true; | ||
if (throwIfNoEntry) { | ||
throw e; | ||
} | ||
else { | ||
return undefined; | ||
} | ||
} | ||
} | ||
//# sourceMappingURL=node-fs.js.map |
{ | ||
"name": "@file-services/node", | ||
"description": "Node.js file system implementation.", | ||
"version": "5.4.3", | ||
"version": "5.7.0", | ||
"main": "dist/index.js", | ||
"scripts": { | ||
"test": "yarn test:node", | ||
"test": "npm run test:node", | ||
"test:node": "mocha \"./dist/test/*.{spec,nodespec}.js\"" | ||
}, | ||
"dependencies": { | ||
"@file-services/types": "^5.4.0", | ||
"@file-services/utils": "^5.4.0" | ||
"@file-services/types": "^5.7.0", | ||
"@file-services/utils": "^5.7.0" | ||
}, | ||
@@ -14,0 +14,0 @@ "files": [ |
@@ -7,5 +7,13 @@ import fs from 'fs'; | ||
import { createFileSystem } from '@file-services/utils'; | ||
import type { IBaseFileSystem, IFileSystem, IFileSystemPath } from '@file-services/types'; | ||
import type { | ||
IBaseFileSystem, | ||
IFileSystem, | ||
IFileSystemPath, | ||
IFileSystemStats, | ||
StatSyncOptions, | ||
} from '@file-services/types'; | ||
import { NodeWatchService, INodeWatchServiceOptions } from './watch-service.js'; | ||
const nodeMajor = parseInt(process.versions.node, 10); | ||
const needsStatPolyfill = nodeMajor < 14; | ||
const caseSensitive = !fs.existsSync(__filename.toUpperCase()); | ||
@@ -29,2 +37,4 @@ | ||
...fs, | ||
statSync: needsStatPolyfill ? statSync : fs.statSync, | ||
lstatSync: needsStatPolyfill ? lstatSync : fs.lstatSync, | ||
promises: { | ||
@@ -36,1 +46,31 @@ ...fs.promises, | ||
} | ||
function statSync(path: string, options?: StatSyncOptions & { throwIfNoEntry?: true }): IFileSystemStats; | ||
function statSync(path: string, options: StatSyncOptions & { throwIfNoEntry: false }): IFileSystemStats | undefined; | ||
function statSync(path: string, options?: StatSyncOptions): IFileSystemStats | undefined { | ||
try { | ||
return fs.statSync(path, options as fs.StatOptions); | ||
} catch (e) { | ||
const throwIfNoEntry = options?.throwIfNoEntry ?? true; | ||
if (throwIfNoEntry) { | ||
throw e; | ||
} else { | ||
return undefined; | ||
} | ||
} | ||
} | ||
function lstatSync(path: string, options?: StatSyncOptions & { throwIfNoEntry?: true }): IFileSystemStats; | ||
function lstatSync(path: string, options: StatSyncOptions & { throwIfNoEntry: false }): IFileSystemStats | undefined; | ||
function lstatSync(path: string, options?: StatSyncOptions): IFileSystemStats | undefined { | ||
try { | ||
return fs.lstatSync(path, options as fs.StatOptions); | ||
} catch (e) { | ||
const throwIfNoEntry = options?.throwIfNoEntry ?? true; | ||
if (throwIfNoEntry) { | ||
throw e; | ||
} else { | ||
return undefined; | ||
} | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
31662
567
Updated@file-services/types@^5.7.0
Updated@file-services/utils@^5.7.0