"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复制代码