1 | const { hasRequiredDeps, hasRequiredFiles, getYarnOrNPMCommand, scanScripts } = require('./utils/jsdetect')
|
2 |
|
3 | module.exports = function() {
|
4 |
|
5 | if (!hasRequiredFiles(['package.json'])) return false
|
6 |
|
7 | if (!hasRequiredDeps(['svelte'])) return false
|
8 |
|
9 | if (hasRequiredDeps(['sapper'])) return false
|
10 |
|
11 |
|
12 |
|
13 | const possibleArgsArrs = scanScripts({
|
14 | preferredScriptsArr: ['dev', 'start', 'run'],
|
15 | preferredCommand: 'npm run dev'
|
16 | })
|
17 |
|
18 | if (possibleArgsArrs.length === 0) {
|
19 |
|
20 | possibleArgsArrs.push(['npm', 'dev'])
|
21 | }
|
22 |
|
23 | return {
|
24 | type: 'svelte',
|
25 | command: getYarnOrNPMCommand(),
|
26 | port: 8888,
|
27 | proxyPort: 5000,
|
28 | env: { ...process.env },
|
29 | possibleArgsArrs,
|
30 | urlRegexp: new RegExp(`(http://)([^:]+:)${5000}(/)?`, 'g'),
|
31 | dist: 'public'
|
32 | }
|
33 | }
|