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 cleanUpPackager (projectDir) {
const result = await Promise.race([
Project.stopAsync(projectDir),
new Promise((resolve, reject) => setTimeout(resolve, 1000, 'stopFailed'))
])
if (result === 'stopFailed') {
// find RN packager pid, attempt to kill manually
try {
const { packagerPid } = await ProjectSettings.readPackagerInfoAsync(projectDir)
process.kill(packagerPid)
} catch (e) {
process.exit(1)
}
}
}
async function cleanUpPackager(projectDir) {
const result = await Promise.race([
Project.stopAsync(projectDir),
new Promise((resolve, reject) => setTimeout(resolve, 1000, 'stopFailed')),
]);
if (result === 'stopFailed') {
// find RN packager pid, attempt to kill manually
try {
const { packagerPid } = await ProjectSettings.readPackagerInfoAsync(projectDir);
process.kill(packagerPid);
} catch (e) {
process.exit(1);
}
}
}
_stopProjectAsync = async projectRoot => {
if (!this.state.projectRoot) {
return false;
}
this._currentOpenProjectXDEId++;
// Send projectRoot to main process.
ipcRenderer.send('project-closed', projectRoot);
try {
await Project.stopAsync(projectRoot);
this._logInfo('Project closed.');
this.setState({
projectSettings: null,
projectRoot: null,
projectJson: null,
computedUrl: null,
isProjectRunning: false,
expJson: null,
logs: [],
connectedDevices: {},
focusedConnectedDeviceId: null,
});
this._resetLocalProperties();
return true;
} catch (err) {
_stopProjectAsync = async (projectRoot) => {
if (!this.state.projectRoot) {
return false;
}
this._currentOpenProjectXDEId++;
// Send projectRoot to main process.
ipcRenderer.send('project-closed', projectRoot);
try {
await Project.stopAsync(projectRoot);
this._logInfo('Project closed.');
this.setState({
projectSettings: null,
projectRoot: null,
projectJson: null,
computedUrl: null,
isProjectRunning: false,
expJson: null,
logs: [],
connectedDevices: {},
focusedConnectedDeviceId: null,
});
this._resetLocalProperties();
return true;
} catch (err) {
await Promise.all(projectRoots.map(root => Project.stopAsync(root)));
} catch (e) {