Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add detector for Expo #672

Merged
merged 2 commits into from
Jan 9, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/detectors/expo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const { hasRequiredDeps, hasRequiredFiles, getYarnOrNPMCommand, scanScripts } = require('./utils/jsdetect')
module.exports = function() {
// REQUIRED FILES
if (!hasRequiredFiles(['package.json', 'app.json'])) return false
// REQUIRED DEPS
if (!hasRequiredDeps(['expo'])) return false

/** everything below now assumes that we are within expo */

const possibleArgsArrs = scanScripts({
// This script will run `expo start --web` in a new Expo project.
// Note: Expo will automatically launch the browser with your app's
// Webpack server listening on port 19006, but the instance proxied
// by `netlify dev` will be running on port 8888.
preferredScriptsArr: ['web'],
preferredCommand: 'expo start --web'
})

if (possibleArgsArrs.length === 0) {
// ofer to run it when the user doesnt have any scripts setup! 🤯
possibleArgsArrs.push(['expo', 'start', '--web'])
}
return {
type: 'expo',
command: getYarnOrNPMCommand(),
port: 8888,
proxyPort: 19006,
env: { ...process.env },
possibleArgsArrs,
urlRegexp: new RegExp(`(http://)([^:]+:)${19006}(/)?`, 'g'),
dist: 'web-build'
}
}