* fix: Add Api challenges - Chinese translation * fix: md formatting * fix: md formatting
2.1 KiB
2.1 KiB
id, title, localeTitle, challengeType
id | title | localeTitle | challengeType |
---|---|---|---|
587d7fb5367417b2b2512c02 | Use the Tilde-Character to Always Use the Latest Patch Version of a Dependency | 使用Tilde-Character始终使用依赖项的最新修补程序版本 | 2 |
Description
0
在上一次挑战中,我们告诉npm只包含特定版本的软件包。如果您需要确保项目的不同部分保持彼此兼容,那么这是一种冻结依赖关系的有用方法。但在大多数用例中,您不希望错过错误修复,因为它们通常包含重要的安全补丁,并且(希望)不会破坏这样做。 0
要允许npm依赖项更新到最新的PATCH版本,可以使用波形符(〜)为依赖项的版本添加前缀。在package.json中,我们关于npm如何升级时刻的当前规则是仅使用特定版本(2.10.2),但我们希望允许最新的2.10.x版本。 0
示例
"some-package-name": "~1.3.8" allows updates to any 1.3.x version.
0
指令0
使用波形符(〜)为依赖项中的时刻版本添加前缀,并允许npm将其更新为任何新的PATCH版本。 0
请注意,不应更改版本号本身。
Instructions
Tests
tests:
- text: '“依赖”应该包括“时刻”'
testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/package.json'').then(data => { var packJson = JSON.parse(data); assert.property(packJson.dependencies, ''moment'', ''"dependencies" does not include "moment"''); }, xhr => { throw new Error(xhr.responseText); })'
- text: '“时刻”版本应匹配“~2.10.2”'
testString: 'getUserInput => $.get(getUserInput(''url'') + ''/_api/package.json'').then(data => { var packJson = JSON.parse(data); assert.match(packJson.dependencies.moment, /^\~2\.10\.2/, ''Wrong version of "moment". It should be ~2.10.2''); }, xhr => { throw new Error(xhr.responseText); })'
Challenge Seed
Solution
// solution required