Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function clonePkg (
from: string,
to: string,
opts: {
filesResponse: PackageFilesResponse,
force: boolean,
},
) {
const pkgJsonPath = path.join(to, 'package.json')
if (!opts.filesResponse.fromStore || opts.force || !await exists(pkgJsonPath)) {
importingLogger.debug({ from, to, method: 'clone' })
await importIndexedDir(cloneFile, from, to, opts.filesResponse.filenames)
}
}
async function hardlinkPkg (
from: string,
to: string,
opts: {
filesResponse: PackageFilesResponse,
force: boolean,
},
) {
const pkgJsonPath = path.join(to, 'package.json')
if (!opts.filesResponse.fromStore || opts.force || !await exists(pkgJsonPath) || !await pkgLinkedToStore(pkgJsonPath, from, to)) {
importingLogger.debug({ from, to, method: 'hardlink' })
await importIndexedDir(fs.link, from, to, opts.filesResponse.filenames)
}
}
export async function copyPkg (
from: string,
to: string,
opts: {
filesResponse: PackageFilesResponse,
force: boolean,
},
) {
const pkgJsonPath = path.join(to, 'package.json')
if (!opts.filesResponse.fromStore || opts.force || !await exists(pkgJsonPath)) {
importingLogger.debug({ from, to, method: 'copy' })
const staging = pathTemp(path.dirname(to))
await makeDir(staging)
await ncp(from + '/.', staging)
await renameOverwrite(staging, to)
}
}