Skip to content

Commit

Permalink
Add detector for Expo
Browse files Browse the repository at this point in the history
  • Loading branch information
ianmartorell committed Jan 7, 2020
1 parent 4e7d443 commit d9dadb7
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/detectors/expo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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({
// prefer the `start:web` script instead of expo's default `web` since that runs
// `expo start --web`, which auto launches the (non-proxied) web browser.
preferredScriptsArr: ['start:web'],
// `expo start:web` does not auto launch the web browser
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'
}
}

0 comments on commit d9dadb7

Please sign in to comment.