Skip to content

Commit e51331c

Browse files
committed
Chore: improve deploy script
- needs rebuild after version bump because the preversion script is in the previous version.
1 parent fabed4c commit e51331c

File tree

2 files changed

+32
-31
lines changed

2 files changed

+32
-31
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"deploy": "node scripts/deploy",
4949
"lint": "eslint . --rulesdir eslint-rules",
5050
"preversion": "run-s lint build -s",
51-
"postversion": "git push && git push --tags && npm run deploy -- --skip-build",
51+
"postversion": "git push && git push --tags && npm run deploy",
5252
"update-deps": "npm install eslint@latest eslint-plugin-vue@next vue-eslint-parser@experimental",
5353
"watch": "cross-env NODE_ENV=development run-p watch:* -s",
5454
"watch:html": "cpx src/index.html dist --watch",

scripts/deploy.js

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,32 @@
11
"use strict"
22

3+
//------------------------------------------------------------------------------
4+
// Requirements
5+
//------------------------------------------------------------------------------
6+
37
const sh = require("shelljs")
48
const version = require("../package.json").version
5-
const skipBuild = (process.argv.indexOf("--skip-build") >= 0)
69

7-
main()
10+
//------------------------------------------------------------------------------
11+
// Helpers
12+
//------------------------------------------------------------------------------
813

914
/**
10-
* Main.
15+
* Execute `cp` command.
1116
* @returns {void}
1217
*/
13-
function main() {
14-
if (!skipBuild) {
15-
exec(`git checkout v${version}`)
16-
exec("npm run build")
17-
}
18-
exec("git checkout gh-pages")
19-
20-
if (String(sh.cat("dist/versions.json")) !== String(sh.cat("versions.json"))) {
21-
rm("-rf", "vs", "index.*")
22-
cp("-r", "dist/*", ".")
23-
exec("git add -A")
24-
exec("git commit -m \"Update: website\"")
25-
exec("git push")
26-
}
27-
28-
exec("git checkout master")
18+
function cp(...args) {
19+
sh.echo(`> cp ${args.join(" ")}`)
20+
sh.cp(...args)
2921
}
3022

3123
/**
32-
* Execute `cp` command.
24+
* Execute `rm` command.
3325
* @returns {void}
3426
*/
35-
function cp(...args) {
36-
sh.echo(`> cp ${args.join(" ")}`)
37-
sh.cp(...args)
27+
function rm(...args) {
28+
sh.echo(`> rm ${args.join(" ")}`)
29+
sh.rm(...args)
3830
}
3931

4032
/**
@@ -50,11 +42,20 @@ function exec(command) {
5042
}
5143
}
5244

53-
/**
54-
* Execute `rm` command.
55-
* @returns {void}
56-
*/
57-
function rm(...args) {
58-
sh.echo(`> rm ${args.join(" ")}`)
59-
sh.rm(...args)
45+
//------------------------------------------------------------------------------
46+
// Main
47+
//------------------------------------------------------------------------------
48+
49+
exec(`git checkout v${version}`)
50+
exec("npm run build")
51+
exec("git checkout gh-pages")
52+
53+
if (String(sh.cat("dist/versions.json")) !== String(sh.cat("versions.json"))) {
54+
rm("-rf", "vs", "index.*")
55+
cp("-r", "dist/*", ".")
56+
exec("git add -A")
57+
exec("git commit -m \"Update: website\"")
58+
exec("git push")
6059
}
60+
61+
exec("git checkout master")

0 commit comments

Comments
 (0)