Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
switchProject(cwd, rootState) {
// If current .cwd
const currentCwd = rootState.project.cwd;
if (currentCwd) {
// Reset both session and project
dispatch.session.resetSession();
dispatch.project.resetProject();
}
// Change local .cwd
this.updateCwd(cwd);
// Add or update history's recent project
dispatch.history.addOrUpdateRecentProject(cwd);
},
},
update = () => {
dispatch.project.updatePackageManager({ packageManager: this });
ParentProcessManager.send(
ParentProcessManager.actions.UPDATE_PACKAGE_MANAGER,
this
);
this.listeners.forEach(callback => callback(this));
};
Promise.all(workers).then(todos => {
todos = todos.filter(currentTodos => currentTodos.length > 0);
dispatch.project.replaceTodos(todos);
});
}
fs.readFile(pathToFile, 'utf-8', (err, code) => {
if (err) return;
this.openFile({ pathToFile, code });
if (temporaryFile) dispatch.project.closeFile(temporaryFile);
dispatch.project.openTemporaryFile(pathToFile);
});
}
static _dispatchNewStatus(filesStatus) {
const currentFileStatus = getState().project.git.filesStatus;
for (const [path, status] of Object.entries(filesStatus)) {
if (currentFileStatus[path] && currentFileStatus[path] === status) {
delete filesStatus[path];
}
}
if (Object.keys(filesStatus).length > 0) {
dispatch.project.updateGitFilesStatus(filesStatus);
}
}
default:
case SwitchPackageManager.NPM:
if (typeof currentPackageManager !== packageManagers.NpmPackageManager) {
packageManager = new packageManagers.NpmPackageManager();
}
break;
case SwitchPackageManager.YARN:
if (typeof currentPackageManager !== packageManagers.YarnPackageManager) {
packageManager = new packageManagers.YarnPackageManager();
}
break;
}
if (packageManager) {
dispatch.project.updatePackageManager({ packageManager });
}
}
fs.rename(filePath, newFilePath, err => {
if (err) return;
dispatch.project.renameOpenedFile({ filePath, newFilePath });
this.renameFile({ filePath, newFilePath });
});
},
fileToFallbackTo = openedFiles[i - 1];
} else if (openedFiles[i + 1]) {
fileToFallbackTo = openedFiles[i + 1];
}
}
}
dispatch.project.closeFile(pathToFile);
if (fileToFallbackTo) {
this.openFile({ pathToFile: fileToFallbackTo.filePath });
} else {
this.cleanCurrentSession();
}
} else {
dispatch.project.closeFile(pathToFile);
}
};
update = () => {
dispatch.project.updateTaskRunner({ taskRunner: this });
};