Skip to content

Commit b10d57d

Browse files
committed
Add deploy script and execa dependency
1 parent 9060b68 commit b10d57d

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@
2323
"serve": "vue-cli-service serve",
2424
"build": "vue-cli-service build",
2525
"lint": "vue-cli-service lint",
26-
"introit": "npm run build && npm run lint && npm run serve"
26+
"introit": "npm run build && npm run lint && npm run serve",
27+
"deploy": "node scripts/gh-pages-deploy.js"
2728
},
2829
"dependencies": {
2930
"typeit": "^7.0.4",
3031
"vue": "^2.7.15",
31-
"vue-particlejs": "1.1.0"
32+
"vue-particlejs": "1.1.0",
33+
"execa": "latest"
3234
},
3335
"devDependencies": {
3436
"@vue/cli-plugin-babel": "^5.0.8",

scripts/gh-pages-deploy.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/* eslint-disable no-console */
2+
const execa = require("execa");
3+
const fs = require("fs");
4+
(async () => {
5+
try {
6+
await execa("git", ["checkout", "--orphan", "gh-pages"]);
7+
// eslint-disable-next-line no-console
8+
console.log("Building started...");
9+
await execa("npm", ["run", "build"]);
10+
// Understand if it's dist or build folder
11+
const folderName = fs.existsSync("dist") ? "dist" : "build";
12+
await execa("git", ["--work-tree", folderName, "add", "--all"]);
13+
await execa("git", ["--work-tree", folderName, "commit", "-m", "gh-pages"]);
14+
console.log("Pushing to gh-pages...");
15+
await execa("git", ["push", "origin", "HEAD:gh-pages", "--force"]);
16+
await execa("rm", ["-r", folderName]);
17+
await execa("git", ["checkout", "-f", "master"]);
18+
await execa("git", ["branch", "-D", "gh-pages"]);
19+
console.log("Successfully deployed, check your settings");
20+
} catch (e) {
21+
// eslint-disable-next-line no-console
22+
console.log(e.message);
23+
process.exit(1);
24+
}
25+
})();

0 commit comments

Comments
 (0)