npm包发布时如何自动同步到github仓库?
已解决
悬赏分:0
- 解决时间 2021-11-27 07:16
点赞 0反对 0举报 0
收藏 0
分享 0
回答4
最佳
-
我只用最简单的shelljs完成操作
"scripts": { "up": "yarn publish --patch", "postpublish": "node push.js" }
push.js
var shell = require('shelljs'); shell.exec('git add .'); shell.exec(`git commit -m ${JSON.stringify(new Date().toLocaleString())}`); shell.exec(`git push origin master`);
支持 0 反对 0 举报2021-11-27 02:36
-
没有自动的功能吧,可以写个脚本同时执行publish和push 至于一步push可借助shelljs执行add、commit、push这些命令
支持 0 反对 0 举报2021-11-27 02:44
-
你可以在prepublishOnly钩子中添加推送命令,都是shell命令,比如在发布前先执行git push和构建发布版本(比如发布命令名称是build-bundle):
"scripts": { "prepublishOnly": "git push && yarn build-bundle" },
支持 0 反对 0 举报2021-11-27 04:04
-
感觉真正实现的过程,跟你的想法恰恰相反,
真实情况应该是,将代码 push 到 github,通过 ci 持续集成工具(如:travis 或 github actions)检测特定分支是否更新,然后再拉取分支自动化发布 npm package。我这里有个就是这样做的可以参考,https://github.com/gauseen/tools
支持 0 反对 0 举报2021-11-27 05:02