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(['vuepress'])) return false
|
8 |
|
9 |
|
10 |
|
11 | const possibleArgsArrs = scanScripts({
|
12 | preferredScriptsArr: ['docs:dev', 'dev', 'run'],
|
13 | preferredCommand: 'vuepress dev'
|
14 | })
|
15 |
|
16 | if (possibleArgsArrs.length === 0) {
|
17 |
|
18 | possibleArgsArrs.push(['vuepress', 'dev'])
|
19 | }
|
20 |
|
21 | return {
|
22 | type: 'vuepress',
|
23 | command: getYarnOrNPMCommand(),
|
24 | port: 8888,
|
25 | proxyPort: 8080,
|
26 | env: { ...process.env },
|
27 | possibleArgsArrs,
|
28 | urlRegexp: new RegExp(`(http://)([^:]+:)${8080}(/)?`, 'g'),
|
29 | dist: '.vuepress/dist'
|
30 | }
|
31 | }
|