From 746abfe54f189b46cd0ba324711ca2792ecfdbdf Mon Sep 17 00:00:00 2001 From: jaywcjlove <398188662@qq.com> Date: Sat, 19 Nov 2016 02:48:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=87=AA=E5=8A=A8=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E9=83=A8=E7=BD=B2=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/deploy.js | 26 ++++++++++++++++++++++++++ package.json | 5 +++++ 2 files changed, 31 insertions(+) create mode 100644 build/deploy.js diff --git a/build/deploy.js b/build/deploy.js new file mode 100644 index 0000000000..e0d7e3ce4e --- /dev/null +++ b/build/deploy.js @@ -0,0 +1,26 @@ +var exec = require('child_process').exec; +var ghpages = require('gh-pages'); +var loading = require('loading-cli'); +var path = require('path'); +var color = require('colors-cli/safe'); +var error = color.red.bold; +var warn = color.yellow; +var notice = color.blue; +var success = color.green; + +var deploy_path = path.join(process.cwd(), '.deploy'); + +if(fs.existsSync(deploy_path)){ + var load = loading(' Pushing code!!') + load.start(); + ghpages.publish(deploy_path,{ + repo: 'https://github.com/jaywcjlove/linux-command.git', + branch: 'gh-pages' + }, function(err) { + if(err) return console.log(error(' → '+"ok!"+err)); + load.stop() + console.log(success('\n\n '+"Push success!!")); + // 删除文件夹 + exec('rm -rf .deploy'); + }); +} diff --git a/package.json b/package.json index 5d39048a1f..b90bc82f6a 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "start": "node build/compile.js", + "deploy": "node build/deploy.js", "build:css": "stylus -u autoprefixer-stylus template/styl/index.styl -o .deploy/ -c", "watch:css": "stylus -u autoprefixer-stylus -w template/styl/index.styl -o .deploy/ -c" }, @@ -29,5 +30,9 @@ "ssr": "^1.1.1", "stylus": "^0.54.5", "watch": "^1.0.1" + }, + "dependencies": { + "gh-pages": "^0.12.0", + "loading-cli": "^1.0.2" } }