Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private async fetchFromDisk(locator: Locator, opts: FetchOptions) {
const {parentLocator, path} = structUtils.parseFileStyleRange(locator.reference, {protocol: PROTOCOL});
// If the file target is an absolute path we can directly access it via its
// location on the disk. Otherwise we must go through the package fs.
const parentFetch = ppath.isAbsolute(path)
? {packageFs: new NodeFS(), prefixPath: PortablePath.root, localPath: PortablePath.root}
: await opts.fetcher.fetch(parentLocator, opts);
// If the package fs publicized its "original location" (for example like
// in the case of "file:" packages), we use it to derive the real location.
const effectiveParentFetch = parentFetch.localPath
? {packageFs: new NodeFS(), prefixPath: parentFetch.localPath}
: parentFetch;
// Discard the parent fs unless we really need it to access the files
if (parentFetch !== effectiveParentFetch && parentFetch.releaseFs)
parentFetch.releaseFs();
private async fetchFromDisk(locator: Locator, opts: FetchOptions) {
const {parentLocator, path} = structUtils.parseFileStyleRange(locator.reference, {protocol: PROTOCOL});
// If the file target is an absolute path we can directly access it via its
// location on the disk. Otherwise we must go through the package fs.
const parentFetch = ppath.isAbsolute(path)
? {packageFs: new NodeFS(), prefixPath: PortablePath.root, localPath: PortablePath.root}
: await opts.fetcher.fetch(parentLocator, opts);
// If the package fs publicized its "original location" (for example like
// in the case of "file:" packages), we use it to derive the real location.
const effectiveParentFetch = parentFetch.localPath
? {packageFs: new NodeFS(), prefixPath: parentFetch.localPath}
: parentFetch;
// Discard the parent fs unless we really need it to access the files
if (parentFetch !== effectiveParentFetch && parentFetch.releaseFs)
parentFetch.releaseFs();
async fetchFromDisk(locator: Locator, opts: FetchOptions) {
const {parentLocator, path} = structUtils.parseFileStyleRange(locator.reference, {protocol: PROTOCOL});
// If the file target is an absolute path we can directly access it via its
// location on the disk. Otherwise we must go through the package fs.
const parentFetch = ppath.isAbsolute(path)
? {packageFs: new NodeFS(), prefixPath: PortablePath.root, localPath: PortablePath.root}
: await opts.fetcher.fetch(parentLocator, opts);
// If the package fs publicized its "original location" (for example like
// in the case of "file:" packages), we use it to derive the real location.
const effectiveParentFetch = parentFetch.localPath
? {packageFs: new NodeFS(), prefixPath: parentFetch.localPath}
: parentFetch;
// Discard the parent fs unless we really need it to access the files
if (parentFetch !== effectiveParentFetch && parentFetch.releaseFs)
parentFetch.releaseFs();
getLocalPath(locator: Locator, opts: FetchOptions) {
const {parentLocator, path} = structUtils.parseFileStyleRange(locator.reference, {protocol: LINK_PROTOCOL});
if (ppath.isAbsolute(path))
return path;
const parentLocalPath = opts.fetcher.getLocalPath(parentLocator, opts);
if (parentLocalPath === null)
return null;
return ppath.resolve(parentLocalPath, path);
}
getLocalPath(locator: Locator, opts: FetchOptions) {
const {parentLocator, path} = structUtils.parseFileStyleRange(locator.reference, {protocol: PROTOCOL});
if (ppath.isAbsolute(path))
return path;
const parentLocalPath = opts.fetcher.getLocalPath(parentLocator, opts);
if (parentLocalPath === null)
return null;
return ppath.resolve(parentLocalPath, path);
}
getLocalPath(locator: Locator, opts: FetchOptions) {
const {parentLocator, path} = structUtils.parseFileStyleRange(locator.reference, {protocol: RAW_LINK_PROTOCOL});
if (ppath.isAbsolute(path))
return path;
const parentLocalPath = opts.fetcher.getLocalPath(parentLocator, opts);
if (parentLocalPath === null)
return null;
return ppath.resolve(parentLocalPath, path);
}
getLocalPath(locator: Locator, opts: FetchOptions) {
const {parentLocator, path} = structUtils.parseFileStyleRange(locator.reference, {protocol: PROTOCOL});
if (ppath.isAbsolute(path))
return path;
const parentLocalPath = opts.fetcher.getLocalPath(parentLocator, opts);
if (parentLocalPath === null)
return null;
return ppath.resolve(parentLocalPath, path);
}