Skip to content

Commit f7cc18d

Browse files
authored
Create Scripts dir
1 parent b927251 commit f7cc18d

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

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)