"scripts": {
"dev": "vue-cli-service serve",
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint",
"deploy": "push-dir --dir=dist --remote=deploy --branch=master",
"push" : "node ./push.js" //新加
}複製代碼
第三步建立push.js文件 和package.json同級push.js文件
vue
//局部模式
var shell = require('shelljs');
//全局模式下,就不須要用shell開頭了。
//require('shelljs/global');
if (shell.exec('npm run build').code !== 0) {//執行npm run build 命令
shell.echo('Error: Git commit failed');
shell.exit(1);
}
//因爲個人用另一個倉庫存放dist目錄,因此這裏要將文件增量複製到目標目錄。並切換到對應目錄。
shell.cp ('-r', './dist/*', '../qindao_frontend_ui_dist');
shell.cd('../qindao_frontend_ui_dist');
shell.exec('git pull origin master');
shell.exec('git add .');
shell.exec("git commit -m 'autocommit'")
shell.exec('git push origin master')
————————————————
版權聲明:本文爲CSDN博主「木貝西」的原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處連接及本聲明。
原文連接:https://blog.csdn.net/weixin_44872995/article/details/100770959複製代碼