Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Discard the parent fs unless we really need it to access the files
if (parentFetch !== effectiveParentFetch && parentFetch.releaseFs)
parentFetch.releaseFs();
const generatorFs = effectiveParentFetch.packageFs;
const generatorPath = ppath.resolve(ppath.resolve(generatorFs.getRealPath(), effectiveParentFetch.prefixPath), path);
// Execute the specified script in the temporary directory
const cwd = await this.generatePackage(locator, generatorPath, opts);
// Make sure the script generated the package
if (!xfs.existsSync(ppath.join(cwd, toFilename(`build`))))
throw new Error(`The script should have generated a build directory`);
return await tgzUtils.makeArchiveFromDirectory(ppath.join(cwd, toFilename(`build`)), {
prefixPath: structUtils.getIdentVendorPath(locator),
});
}
async fetch(locator: Locator, opts: FetchOptions) {
const expectedChecksum = opts.checksums.get(locator.locatorHash) || null;
const [packageFs, releaseFs, checksum] = await opts.cache.fetchPackageFromCache(
locator,
expectedChecksum,
async () => {
opts.report.reportInfoOnce(MessageName.FETCH_NOT_CACHED, `${structUtils.prettyLocator(opts.project.configuration, locator)} can't be found in the cache and will be fetched from the disk`);
return await this.patchPackage(locator, opts);
},
);
return {
packageFs,
releaseFs,
prefixPath: structUtils.getIdentVendorPath(locator),
localPath: this.getLocalPath(locator, opts),
checksum,
};
}
await tgzUtils.extractArchiveTo(sourceBuffer, extractTarget, {
stripComponents: 1,
});
const packagePath = ppath.join(extractPath, `package.tgz` as PortablePath);
await scriptUtils.prepareExternalProject(extractPath, packagePath, {
configuration: opts.project.configuration,
report: opts.report,
});
const packedBuffer = await xfs.readFilePromise(packagePath);
return await tgzUtils.convertToZip(packedBuffer, {
stripComponents: 1,
prefixPath: structUtils.getIdentVendorPath(locator),
});
}
async fetch(locator: Locator, opts: FetchOptions) {
const expectedChecksum = opts.checksums.get(locator.locatorHash) || null;
const [packageFs, releaseFs, checksum] = await opts.cache.fetchPackageFromCache(
locator,
expectedChecksum,
async () => {
opts.report.reportInfoOnce(MessageName.FETCH_NOT_CACHED, `${structUtils.prettyLocator(opts.project.configuration, locator)} can't be found in the cache and will be fetched from the disk`);
return await this.fetchFromDisk(locator, opts);
},
);
return {
packageFs,
releaseFs,
prefixPath: structUtils.getIdentVendorPath(locator),
localPath: this.getLocalPath(locator, opts),
checksum,
};
}
return await miscUtils.releaseAfterUseAsync(async () => {
return await tgzUtils.convertToZip(sourceBuffer, {
stripComponents: 1,
prefixPath: structUtils.getIdentVendorPath(locator),
});
}, effectiveParentFetch.releaseFs);
}
async fetch(locator: Locator, opts: FetchOptions) {
const expectedChecksum = opts.checksums.get(locator.locatorHash) || null;
const [packageFs, releaseFs, checksum] = await opts.cache.fetchPackageFromCache(
locator,
expectedChecksum,
async () => {
opts.report.reportInfoOnce(MessageName.FETCH_NOT_CACHED, `${structUtils.prettyLocator(opts.project.configuration, locator)} can't be found in the cache and will be fetched from the remote repository`);
return await this.fetchFromNetwork(locator, opts);
},
);
return {
packageFs,
releaseFs,
prefixPath: structUtils.getIdentVendorPath(locator),
checksum,
};
}
async fetch(locator: Locator, opts: FetchOptions) {
const expectedChecksum = opts.checksums.get(locator.locatorHash) || null;
const [packageFs, releaseFs, checksum] = await opts.cache.fetchPackageFromCache(
locator,
expectedChecksum,
async () => {
opts.report.reportInfoOnce(MessageName.FETCH_NOT_CACHED, `${structUtils.prettyLocator(opts.project.configuration, locator)} can't be found in the cache and will be fetched from the remote server`);
return await this.fetchFromNetwork(locator, opts);
},
);
return {
packageFs,
releaseFs,
prefixPath: structUtils.getIdentVendorPath(locator),
checksum,
};
}
async fetch(locator: Locator, opts: FetchOptions) {
const expectedChecksum = opts.checksums.get(locator.locatorHash) || null;
const [packageFs, releaseFs, checksum] = await opts.cache.fetchPackageFromCache(
locator,
expectedChecksum,
async () => {
opts.report.reportInfoOnce(MessageName.FETCH_NOT_CACHED, `${structUtils.prettyLocator(opts.project.configuration, locator)} can't be found in the cache and will be fetched from the disk`);
return await this.fetchFromDisk(locator, opts);
},
);
return {
packageFs,
releaseFs,
prefixPath: structUtils.getIdentVendorPath(locator),
checksum,
};
}
return await miscUtils.releaseAfterUseAsync(async () => {
return await tgzUtils.convertToZip(sourceBuffer, {
stripComponents: 1,
prefixPath: structUtils.getIdentVendorPath(locator),
});
});
}