gpt4 book ai didi

javascript - 如何将时间戳添加到 package.json 中的脚本中?

转载 作者:数据小太阳 更新时间:2023-10-29 04:29:51 25 4
gpt4 key购买 nike

这可能是不可能的(因为这是 JSON 而不是 JavaScript)。我只是在想最简单的方法来从 npm 命令在字符串中插入日期戳,而不增加另一个任务运行器等的开销:

"scripts": {
"deploy" : "git add -A; git commit -m \"automated deployment {DateStamp}\"; git push deployment browse --force;"
},

而且不用因为使用 --force 而责备我 ;)

最佳答案

NPM 脚本只是 bash 脚本。使用 bash 功能为某些提交消息添加时间戳。示例:

  "scripts": {
"deploy" : "git add -A; timestamp=$(date \"+%s\") && git commit -m \"automated deployment $timestamp\"; git push deployment browse --force;"
},

关于javascript - 如何将时间戳添加到 package.json 中的脚本中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33151617/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com