Skip to content
This repository was archived by the owner on Sep 12, 2019. It is now read-only.

Commit 44ad5cc

Browse files
author
sw-yx
committed
2 parents b75bacb + bb6c3d1 commit 44ad5cc

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

src/detectors/sapper.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const {
2+
hasRequiredDeps,
3+
hasRequiredFiles,
4+
getYarnOrNPMCommand,
5+
scanScripts
6+
} = require("./utils/jsdetect");
7+
8+
module.exports = function() {
9+
// REQUIRED FILES
10+
if (!hasRequiredFiles(["package.json"])) return false;
11+
// REQUIRED DEPS
12+
if (!hasRequiredDeps(["sapper"])) return false;
13+
14+
/** everything below now assumes that we are within vue */
15+
16+
const possibleArgsArrs = scanScripts({
17+
preferredScriptsArr: ["dev", "start"],
18+
preferredCommand: "sapper dev"
19+
});
20+
21+
if (possibleArgsArrs.length === 0) {
22+
// ofer to run it when the user doesnt have any scripts setup! 🤯
23+
possibleArgsArrs.push(["sapper", "dev"]);
24+
}
25+
26+
return {
27+
type: "vue-cli",
28+
command: getYarnOrNPMCommand(),
29+
port: 8888,
30+
proxyPort: 3000,
31+
env: { ...process.env },
32+
possibleArgsArrs,
33+
urlRegexp: new RegExp(`(http://)([^:]+:)${3000}(/)?`, "g"),
34+
dist: "dist"
35+
};
36+
};

src/detectors/svelte.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const {
2+
hasRequiredDeps,
3+
hasRequiredFiles,
4+
getYarnOrNPMCommand,
5+
scanScripts
6+
} = require("./utils/jsdetect");
7+
8+
module.exports = function() {
9+
// REQUIRED FILES
10+
if (!hasRequiredFiles(["package.json"])) return false;
11+
// REQUIRED DEPS
12+
if (!hasRequiredDeps(["svelte"])) return false;
13+
14+
/** everything below now assumes that we are within vue */
15+
16+
const possibleArgsArrs = scanScripts({
17+
preferredScriptsArr: ["dev", "start", "run"],
18+
preferredCommand: "npm run dev"
19+
});
20+
21+
if (possibleArgsArrs.length === 0) {
22+
// ofer to run it when the user doesnt have any scripts setup! 🤯
23+
possibleArgsArrs.push(["npm", "dev"]);
24+
}
25+
26+
return {
27+
type: "svelte",
28+
command: getYarnOrNPMCommand(),
29+
port: 8888,
30+
proxyPort: 5000,
31+
env: { ...process.env },
32+
possibleArgsArrs,
33+
urlRegexp: new RegExp(`(http://)([^:]+:)${5000}(/)?`, "g"),
34+
dist: "dist"
35+
};
36+
};

0 commit comments

Comments
 (0)