not*_*ffy 8 bash shell automation json
这是我的 package.json 文件
{
"name": "project-1",
"version": "1.0.0",
"description": "TestCafe project",
"main": "index.js",
"scripts": {
"ci:build": "npm ci",
"test": "testcafe",
"precise-commits": "precise-commits"
},
"repository": {
"type": "git",
"url": "http://github.com/dev/test/testcafe-test"
},
"author": "Tom",
"license": "ISC",
"devDependencies": {
"precise-commits": "^1.0.2",
"prettier": "^1.16.4",
"random-words": "^1.1.0",
"testcafe": "^1.8.0"
},
"dependencies": {
"page-objects": "1.6.169"
}
}
Run Code Online (Sandbox Code Playgroud)
我需要将页面对象版本从 1.6.169 更新到 1.6.170,当我们更改页面对象版本时,这是我编写的 bash 文件
#!/bin/bash
PROJECT=${1?Error: No test project directory passed}
NEW_VERSION=${2?Error: Pass new version}
echo "Updating page object version for ${PROJECT} project"
cd ~/git/master/test/${PROJECT}
CURRENT_VERSION=$(node -p "require('./package.json').version") # here it gives me the
# version of json which is 1.0.0 but i need 1.6.169
sed -i '' "s/${CURRENT_VERSION}/${NEW_VERSION}/" package.json
echo $CURRENT_VERSION
#npm i
Run Code Online (Sandbox Code Playgroud)
我怎样才能得到1.6.69?
| 归档时间: |
|
| 查看次数: |
6835 次 |
| 最近记录: |