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 sendUrlAsync(url, recipient) {
log('Sending URL to', recipient);
simpleSpinner.start();
try {
var result = await Exp.sendAsync(recipient, url);
} finally {
simpleSpinner.stop();
}
log('Sent.');
return result;
}
await UserSettings.mergeAsync({'confirmBeforePublish': false});
} else if (choice === 2) {
return;
}
}
this._logInfo("Publishing...");
try {
let result = await Project.publishAsync(this.state.projectRoot);
this._logInfo(`Published to ${result.url}`);
let notificationMessage = 'Project published successfully.';
let sendTo = this.state.sendTo;
if (sendTo) {
try {
await Exp.sendAsync(sendTo, result.url);
this._logInfo(`Sent link ${result.url} to ${sendTo}.`);
} catch (err) {
this._logError(`Could not send link to ${sendTo}: ${err}`);
}
notificationMessage = `${notificationMessage} Sent to ${sendTo}`;
}
this._showNotification('success', notificationMessage);
} catch (err) {
this._showNotification('error', 'Project failed to publish.');
this._logError(`Failed to publish package: ${err.message}`);
}
};
_sendClickedAsync = async sendTo => {
Analytics.logEvent('Click Send');
this.setState({ sendTo });
let url_ = this.state.computedUrl;
try {
await Exp.sendAsync(sendTo, url_);
this._logInfo(`Sent link ${url_} to ${sendTo}.`);
} catch (err) {
this._logError(`Could not send link to ${sendTo}: ${err}`);
this._logError(
"If you're trying to SMS a link to a mobile device, make sure you are using the `+` sign and the country code at the beginning of the number."
);
return;
}
await UserSettings.setAsync('sendTo', sendTo);
};
_sendClickedAsync = async (sendTo) => {
Analytics.logEvent('Click Send');
this.setState({sendTo});
let url_ = this.state.computedUrl;
try {
await Exp.sendAsync(sendTo, url_);
this._logInfo(`Sent link ${url_} to ${sendTo}.`);
UserSettings.updateAsync('sendTo', sendTo);
} catch (err) {
this._logError(`Could not send link to ${sendTo}: ${err}`);
this._logError("If you're trying to SMS a link to a mobile device, make sure you are using the `+` sign and the country code at the beginning of the number.");
}
};
rl.question(defaultRecipient ? `[default: ${defaultRecipient}]> ` : '> ', async sendTo => {
cleanup()
if (!sendTo && defaultRecipient) {
sendTo = defaultRecipient
}
sendTo = sendTo && sendTo.trim()
if (!sendTo) {
cancel()
return
}
log.withTimestamp(`Sending ${lanAddress} to ${sendTo}...`)
let sent = false
try {
await Exp.sendAsync(sendTo, lanAddress, true)
log.withTimestamp(`Sent link successfully.`)
sent = true
} catch (err) {
log.withTimestamp(`Could not send link. ${err}`)
}
printUsage()
if (sent) {
await UserSettings.setAsync('sendTo', sendTo)
}
})
return
rl.question(defaultRecipient ? `[default: ${defaultRecipient}]> ` : '> ', async sendTo => {
cleanup();
if (!sendTo && defaultRecipient) {
sendTo = defaultRecipient;
}
sendTo = sendTo && sendTo.trim();
if (!sendTo) {
cancel();
return;
}
log.withTimestamp(`Sending ${lanAddress} to ${sendTo}...`);
let sent = false;
try {
await Exp.sendAsync(sendTo, lanAddress, true);
log.withTimestamp(`Sent link successfully.`);
sent = true;
} catch (err) {
log.withTimestamp(`Could not send link. ${err}`);
}
printUsage();
if (sent) {
await UserSettings.setAsync('sendTo', sendTo);
}
});
return;
}
}
this._logInfo('Publishing...');
try {
let result = await Project.publishAsync(this.state.projectRoot);
await new Promise(resolve => {
requestAnimationFrame(resolve);
});
this._logInfo(`Published to ${result.url}`);
let notificationMessage = 'Project published successfully.';
let sendTo = this.state.sendTo;
if (sendTo) {
try {
await Exp.sendAsync(sendTo, result.url);
this._logInfo(`Sent link ${result.url} to ${sendTo}.`);
} catch (err) {
this._logError(`Could not send link to ${sendTo}: ${err}`);
}
notificationMessage = `${notificationMessage} Sent to ${sendTo}`;
}
this._showNotification('success', notificationMessage);
} catch (err) {
this._showNotification('error', 'Project failed to publish.');
this._logError(`Failed to publish package: ${err.message}`);
}
};