UNPKG

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