Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const promise: Promise = (async () => {
try {
await removeDir(dstDir, {excludeNodeModules: keepNodeModules});
if (linkType === LinkType.SOFT) {
await xfs.mkdirpPromise(ppath.dirname(dstDir));
await xfs.symlinkPromise(srcDir, dstDir);
} else {
const archivePath = getArchivePath(srcDir);
if (archivePath) {
const prefixInsideArchive = srcDir.substring(archivePath.length);
await xfs.createReadStream(archivePath)
.pipe(unzipper.Parse({concurrency: 8}))
.on('entry', (entry) => {
if (entry.path.length <= prefixInsideArchive.length) {
entry.autodrain();
} else {
const entryName = entry.path.substring(prefixInsideArchive.length);
const fullPath = ppath.join(dstDir, entryName);
if (entry.type === 'Directory') {
xfs.mkdirpSync(fullPath, {chmod: 0o777});
entry.autodrain();
} else {
xfs.mkdirpSync(ppath.dirname(fullPath), {chmod: 0o777});
entry.pipe(fs.createWriteStream(fullPath));