function _cleanInstallFolder()

in common/scripts/install-run.js [311:330]


function _cleanInstallFolder(rushTempFolder, packageInstallFolder) {
    try {
        const flagFile = path.resolve(packageInstallFolder, INSTALLED_FLAG_FILENAME);
        if (fs.existsSync(flagFile)) {
            fs.unlinkSync(flagFile);
        }
        const packageLockFile = path.resolve(packageInstallFolder, 'package-lock.json');
        if (fs.existsSync(packageLockFile)) {
            fs.unlinkSync(packageLockFile);
        }
        const nodeModulesFolder = path.resolve(packageInstallFolder, NODE_MODULES_FOLDER_NAME);
        if (fs.existsSync(nodeModulesFolder)) {
            const rushRecyclerFolder = _ensureAndJoinPath(rushTempFolder, 'rush-recycler');
            fs.renameSync(nodeModulesFolder, path.join(rushRecyclerFolder, `install-run-${Date.now().toString()}`));
        }
    }
    catch (e) {
        throw new Error(`Error cleaning the package install folder (${packageInstallFolder}): ${e}`);
    }
}