UNPKG

916 BJavaScriptView Raw
1const { hasRequiredDeps, hasRequiredFiles, getYarnOrNPMCommand, scanScripts } = require('./utils/jsdetect')
2module.exports = function() {
3 // REQUIRED FILES
4 if (!hasRequiredFiles(['package.json', 'gatsby-config.js'])) return false
5 // REQUIRED DEPS
6 if (!hasRequiredDeps(['gatsby'])) return false
7
8 /** everything below now assumes that we are within gatsby */
9
10 const possibleArgsArrs = scanScripts({
11 preferredScriptsArr: ['start', 'develop', 'dev'],
12 preferredCommand: 'gatsby develop'
13 })
14
15 if (possibleArgsArrs.length === 0) {
16 // ofer to run it when the user doesnt have any scripts setup! 🤯
17 possibleArgsArrs.push(['gatsby', 'develop'])
18 }
19 return {
20 type: 'gatsby',
21 command: getYarnOrNPMCommand(),
22 port: 8888,
23 proxyPort: 8000,
24 env: { ...process.env },
25 possibleArgsArrs,
26 urlRegexp: new RegExp(`(http://)([^:]+:)${8000}(/)?`, 'g'),
27 dist: 'public'
28 }
29}