Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Subscribe to device updates separately from packager/server updates
ProjectUtils.attachLoggerStream(projectDir, {
stream: {
write: chunk => {
if (chunk.tag === 'device') {
handleLogChunk(chunk)
}
}
},
type: 'raw'
})
installExitHooks(projectDir, isInteractive)
log.withTimestamp('Starting packager...')
Project.startAsync(projectDir, options).then(
() => {},
reason => {
log.withTimestamp(chalk.red(`Error starting packager: ${reason.stack}`))
process.exit(1)
}
)
}
// Subscribe to device updates separately from packager/server updates
ProjectUtils.attachLoggerStream(projectDir, {
stream: {
write: chunk => {
if (chunk.tag === 'device') {
handleLogChunk(chunk);
}
},
},
type: 'raw',
});
installExitHooks(projectDir, isInteractive);
log.withTimestamp('Starting packager...');
Project.startAsync(projectDir, options).then(
() => {},
reason => {
log.withTimestamp(chalk.red(`Error starting packager: ${reason.stack}`));
process.exit(1);
}
);
}
}, async () => {
// TODO: refactor this. can't call _startProjectAsync and _stopProjectAsync
// because they rely on state.
try {
await Project.startAsync(this.state.projectRoot);
this._logInfo('Project opened.');
} catch (err) {
this._logError(err.message);
}
let computedUrl = await this._computeUrlAsync();
this.setState({
computedUrl,
isProjectRunning: true,
});
});
};
async () => {
// TODO: refactor this. can't call _startProjectAsync and _stopProjectAsync
// because they rely on setState calls that work asynchronously.
let expJson;
try {
expJson = await Project.startAsync(this.state.projectRoot, { reset });
this._logInfo(PROJECT_OPENED_MESSAGE);
} catch (err) {
this._logError(err.message);
}
let computedUrl = await this._computeUrlAsync(this.state.projectRoot);
let expoSdkStatus = await Doctor.getExpoSdkStatus(this.state.projectRoot);
this.setState({
computedUrl,
isProjectRunning: true,
expJson,
expoSdkStatus,
isLoading: false,
});
}
);
});
return;
}
case 'q':
clearConsole();
await printServerInfo();
return;
case 'r':
case 'R': {
clearConsole();
const reset = key === 'R';
if (reset) {
log.withTimestamp('Asking packager to reset its cache...');
}
log.withTimestamp('Restarting packager...');
Project.startAsync(process.cwd(), { reset });
return;
}
case 'd':
clearConsole();
dev = !dev;
await ProjectSettings.setAsync(process.cwd(), { dev });
log(
`Packager now running in ${chalk.bold(dev ? 'development' : 'production')}${chalk.reset(` mode.`)}
Please close and reopen the project in the Expo app for the
change to take effect.`
);
printUsage();
return;
}
}
);
}
installExitHooks(projectDir);
await urlOpts.optsAsync(projectDir, options);
log(chalk.gray('Using project at', projectDir));
let root = path.resolve(projectDir);
let startOpts = {};
if (options.clear) {
startOpts.reset = true;
}
await Project.startAsync(root, startOpts);
log('Expo is ready.');
let url = await UrlUtils.constructManifestUrlAsync(projectDir);
let { exp } = await ProjectUtils.readConfigJsonAsync(projectDir);
if (!exp.isDetached) {
log('You can scan this QR code:\n');
urlOpts.printQRCode(url);
}
log('Your URL is\n\n' + chalk.underline(url) + '\n');
log.raw(url);
const recipient = await sendTo.getRecipient(options.sendTo);
const nonInteractive = options.parent && options.parent.nonInteractive;
if (!nonInteractive && !exp.isDetached) {
if (await UserSettings.getAsync('openDevToolsAtStartup', true)) {
log(`Opening DevTools in the browser... (press ${chalk.bold`shift-d`} to disable)`);
opn(devToolsUrl, { wait: false });
} else {
log(
`Press ${chalk.bold`d`} to open DevTools now, or ${chalk.bold`shift-d`} to always open it automatically.`
);
}
}
const startOpts = await parseStartOptionsAsync(projectDir, options);
await Project.startAsync(rootPath, startOpts);
await Web.logURL(projectDir);
const url = await UrlUtils.constructManifestUrlAsync(projectDir);
const recipient = await sendTo.getRecipient(options.sendTo);
if (recipient) {
await sendTo.sendUrlAsync(url, recipient);
}
await urlOpts.handleMobileOptsAsync(projectDir, options);
if (!nonInteractive && !exp.isDetached) {
await TerminalUI.startAsync(projectDir, startOpts);
} else if (!options.webOnly) {
if (!exp.isDetached) {
log.newLine();
}, async () => {
try {
let expJson = await Project.startAsync(projectRoot);
this._logInfo('Project opened.');
let computedUrl = await this._computeUrlAsync(projectRoot);
this.setState({
computedUrl,
isProjectRunning: true,
expJson,
});
} catch (err) {
this._logError(err.message);
}
});
async () => {
try {
let expJson = await Project.startAsync(projectRoot);
this._logInfo(PROJECT_OPENED_MESSAGE);
let computedUrl = await this._computeUrlAsync(projectRoot);
let expoSdkStatus = await Doctor.getExpoSdkStatus(projectRoot);
this._getRecentProjects();
this.setState({
computedUrl,
isProjectRunning: true,
expJson,
expoSdkStatus,
isLoading: false,
});
} catch (err) {
this._logError(err.message);
}
}
await urlOpts.optsAsync(projectDir, options);
log(chalk.gray('Using project at', projectDir));
let root = path.resolve(projectDir);
let startOpts = {};
if (options.clear) {
startOpts.reset = true;
}
if (options.maxWorkers) {
startOpts.maxWorkers = options.maxWorkers;
}
await Project.startAsync(root, startOpts);
log('Expo is ready.');
log.newLine();
let { url, isUrlFallback } = await Project.getManifestUrlWithFallbackAsync(projectDir);
let { exp } = await ProjectUtils.readConfigJsonAsync(projectDir);
if (!exp.isDetached) {
urlOpts.printQRCode(url);
}
log('Your URL is: ' + chalk.underline(url));
if (!exp.isDetached) {
await printRunInstructionsAsync();