Skip to content

Commit 746abfe

Browse files
committed
添加自动上传部署代码
1 parent d5c0728 commit 746abfe

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

build/deploy.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
var exec = require('child_process').exec;
2+
var ghpages = require('gh-pages');
3+
var loading = require('loading-cli');
4+
var path = require('path');
5+
var color = require('colors-cli/safe');
6+
var error = color.red.bold;
7+
var warn = color.yellow;
8+
var notice = color.blue;
9+
var success = color.green;
10+
11+
var deploy_path = path.join(process.cwd(), '.deploy');
12+
13+
if(fs.existsSync(deploy_path)){
14+
var load = loading(' Pushing code!!')
15+
load.start();
16+
ghpages.publish(deploy_path,{
17+
repo: 'https://github.com/jaywcjlove/linux-command.git',
18+
branch: 'gh-pages'
19+
}, function(err) {
20+
if(err) return console.log(error(' → '+"ok!"+err));
21+
load.stop()
22+
console.log(success('\n\n '+"Push success!!"));
23+
// 删除文件夹
24+
exec('rm -rf .deploy');
25+
});
26+
}

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"scripts": {
77
"test": "echo \"Error: no test specified\" && exit 1",
88
"start": "node build/compile.js",
9+
"deploy": "node build/deploy.js",
910
"build:css": "stylus -u autoprefixer-stylus template/styl/index.styl -o .deploy/ -c",
1011
"watch:css": "stylus -u autoprefixer-stylus -w template/styl/index.styl -o .deploy/ -c"
1112
},
@@ -29,5 +30,9 @@
2930
"ssr": "^1.1.1",
3031
"stylus": "^0.54.5",
3132
"watch": "^1.0.1"
33+
},
34+
"dependencies": {
35+
"gh-pages": "^0.12.0",
36+
"loading-cli": "^1.0.2"
3237
}
3338
}

0 commit comments

Comments
 (0)