@file-services/overlay
Advanced tools
Comparing version 1.0.5 to 2.0.0
@@ -5,11 +5,11 @@ "use strict"; | ||
function createOverlayFs(lowerFs, upperFs, baseDirectoryPath = lowerFs.cwd()) { | ||
const { promises: lowerPromises, path: lowerPath } = lowerFs; | ||
const { promises: lowerPromises } = lowerFs; | ||
const { promises: upperPromises } = upperFs; | ||
const lowerFsRelativeUp = `..${lowerPath.sep}`; | ||
const lowerFsRelativeUp = `..${lowerFs.sep}`; | ||
// ensure base Directory is absolute | ||
baseDirectoryPath = lowerPath.resolve(baseDirectoryPath); | ||
baseDirectoryPath = lowerFs.resolve(baseDirectoryPath); | ||
function resolvePaths(path) { | ||
const resolvedLowerPath = lowerPath.resolve(path); | ||
const relativeToBase = lowerPath.relative(baseDirectoryPath, resolvedLowerPath); | ||
if (!relativeToBase.startsWith(lowerFsRelativeUp) && !lowerPath.isAbsolute(lowerFsRelativeUp)) { | ||
const resolvedLowerPath = lowerFs.resolve(path); | ||
const relativeToBase = lowerFs.relative(baseDirectoryPath, resolvedLowerPath); | ||
if (!relativeToBase.startsWith(lowerFsRelativeUp) && !lowerFs.isAbsolute(lowerFsRelativeUp)) { | ||
return { resolvedLowerPath, resolvedUpperPath: relativeToBase.replace(/\\/g, '/') }; | ||
@@ -71,3 +71,3 @@ } | ||
try { | ||
return lowerPath.join(baseDirectoryPath, upperFs.realpathSync(resolvedUpperPath)); | ||
return lowerFs.join(baseDirectoryPath, upperFs.realpathSync(resolvedUpperPath)); | ||
} | ||
@@ -161,3 +161,3 @@ catch (_a) { | ||
try { | ||
return lowerPath.join(baseDirectoryPath, await upperPromises.realpath(resolvedUpperPath)); | ||
return lowerFs.join(baseDirectoryPath, await upperPromises.realpath(resolvedUpperPath)); | ||
} | ||
@@ -282,3 +282,3 @@ catch (_a) { | ||
else { | ||
callback(e, lowerPath.join(baseDirectoryPath, realPath)); | ||
callback(e, lowerFs.join(baseDirectoryPath, realPath)); | ||
} | ||
@@ -285,0 +285,0 @@ }); |
import { createFileSystem } from '@file-services/utils'; | ||
export function createOverlayFs(lowerFs, upperFs, baseDirectoryPath = lowerFs.cwd()) { | ||
const { promises: lowerPromises, path: lowerPath } = lowerFs; | ||
const { promises: lowerPromises } = lowerFs; | ||
const { promises: upperPromises } = upperFs; | ||
const lowerFsRelativeUp = `..${lowerPath.sep}`; | ||
const lowerFsRelativeUp = `..${lowerFs.sep}`; | ||
// ensure base Directory is absolute | ||
baseDirectoryPath = lowerPath.resolve(baseDirectoryPath); | ||
baseDirectoryPath = lowerFs.resolve(baseDirectoryPath); | ||
function resolvePaths(path) { | ||
const resolvedLowerPath = lowerPath.resolve(path); | ||
const relativeToBase = lowerPath.relative(baseDirectoryPath, resolvedLowerPath); | ||
if (!relativeToBase.startsWith(lowerFsRelativeUp) && !lowerPath.isAbsolute(lowerFsRelativeUp)) { | ||
const resolvedLowerPath = lowerFs.resolve(path); | ||
const relativeToBase = lowerFs.relative(baseDirectoryPath, resolvedLowerPath); | ||
if (!relativeToBase.startsWith(lowerFsRelativeUp) && !lowerFs.isAbsolute(lowerFsRelativeUp)) { | ||
return { resolvedLowerPath, resolvedUpperPath: relativeToBase.replace(/\\/g, '/') }; | ||
@@ -68,3 +68,3 @@ } | ||
try { | ||
return lowerPath.join(baseDirectoryPath, upperFs.realpathSync(resolvedUpperPath)); | ||
return lowerFs.join(baseDirectoryPath, upperFs.realpathSync(resolvedUpperPath)); | ||
} | ||
@@ -158,3 +158,3 @@ catch (_a) { | ||
try { | ||
return lowerPath.join(baseDirectoryPath, await upperPromises.realpath(resolvedUpperPath)); | ||
return lowerFs.join(baseDirectoryPath, await upperPromises.realpath(resolvedUpperPath)); | ||
} | ||
@@ -279,3 +279,3 @@ catch (_a) { | ||
else { | ||
callback(e, lowerPath.join(baseDirectoryPath, realPath)); | ||
callback(e, lowerFs.join(baseDirectoryPath, realPath)); | ||
} | ||
@@ -282,0 +282,0 @@ }); |
{ | ||
"name": "@file-services/overlay", | ||
"description": "Overlay files and directories from one file system on top of another.", | ||
"version": "1.0.5", | ||
"version": "2.0.0", | ||
"main": "cjs/index.js", | ||
@@ -17,4 +17,4 @@ "module": "esm/index.js", | ||
"dependencies": { | ||
"@file-services/types": "^1.0.4", | ||
"@file-services/utils": "^1.0.4" | ||
"@file-services/types": "^2.0.0", | ||
"@file-services/utils": "^2.0.0" | ||
}, | ||
@@ -34,3 +34,3 @@ "files": [ | ||
"sideEffects": false, | ||
"gitHead": "5324bae9c23054284cb0727692dae2b6a1cb1560" | ||
"gitHead": "1a5d5c8e7ab35d213ba47fe0585ec5887df08d7c" | ||
} |
@@ -17,14 +17,14 @@ import { | ||
): IFileSystem { | ||
const { promises: lowerPromises, path: lowerPath } = lowerFs; | ||
const { promises: lowerPromises } = lowerFs; | ||
const { promises: upperPromises } = upperFs; | ||
const lowerFsRelativeUp = `..${lowerPath.sep}`; | ||
const lowerFsRelativeUp = `..${lowerFs.sep}`; | ||
// ensure base Directory is absolute | ||
baseDirectoryPath = lowerPath.resolve(baseDirectoryPath); | ||
baseDirectoryPath = lowerFs.resolve(baseDirectoryPath); | ||
function resolvePaths(path: string): { resolvedLowerPath: string; resolvedUpperPath?: string } { | ||
const resolvedLowerPath = lowerPath.resolve(path); | ||
const relativeToBase = lowerPath.relative(baseDirectoryPath, resolvedLowerPath); | ||
const resolvedLowerPath = lowerFs.resolve(path); | ||
const relativeToBase = lowerFs.relative(baseDirectoryPath, resolvedLowerPath); | ||
if (!relativeToBase.startsWith(lowerFsRelativeUp) && !lowerPath.isAbsolute(lowerFsRelativeUp)) { | ||
if (!relativeToBase.startsWith(lowerFsRelativeUp) && !lowerFs.isAbsolute(lowerFsRelativeUp)) { | ||
return { resolvedLowerPath, resolvedUpperPath: relativeToBase.replace(/\\/g, '/') }; | ||
@@ -82,3 +82,3 @@ } else { | ||
try { | ||
return lowerPath.join(baseDirectoryPath, upperFs.realpathSync(resolvedUpperPath)); | ||
return lowerFs.join(baseDirectoryPath, upperFs.realpathSync(resolvedUpperPath)); | ||
} catch { | ||
@@ -167,3 +167,3 @@ /**/ | ||
try { | ||
return lowerPath.join(baseDirectoryPath, await upperPromises.realpath(resolvedUpperPath)); | ||
return lowerFs.join(baseDirectoryPath, await upperPromises.realpath(resolvedUpperPath)); | ||
} catch { | ||
@@ -279,3 +279,3 @@ /**/ | ||
} else { | ||
callback(e, lowerPath.join(baseDirectoryPath, realPath)); | ||
callback(e, lowerFs.join(baseDirectoryPath, realPath)); | ||
} | ||
@@ -282,0 +282,0 @@ }); |
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
65591
+ Added@file-services/types@2.2.0(transitive)
+ Added@file-services/utils@2.2.0(transitive)
- Removed@file-services/types@1.0.4(transitive)
- Removed@file-services/utils@1.0.4(transitive)
Updated@file-services/types@^2.0.0
Updated@file-services/utils@^2.0.0