Files
freeCodeCamp/curriculum/challenges/chinese/05-apis-and-microservices/managing-packages-with-npm/use-the-tilde-character-to-always-use-the-latest-patch-version-of-a-dependency.chinese.md
Beau Carnes 6b1992ee7c fix: Add Api challenges - Chinese translation (#35164)
* fix: Add Api challenges - Chinese translation

* fix: md formatting

* fix: md formatting
2019-05-06 06:31:26 -05:00

44 lines
2.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
id: 587d7fb5367417b2b2512c02
title: Use the Tilde-Character to Always Use the Latest Patch Version of a Dependency
localeTitle: 使用Tilde-Character始终使用依赖项的最新修补程序版本
challengeType: 2
---
## Description
<section id='description'> <code>0</code>在上一次挑战中我们告诉npm只包含特定版本的软件包。如果您需要确保项目的不同部分保持彼此兼容那么这是一种冻结依赖关系的有用方法。但在大多数用例中您不希望错过错误修复因为它们通常包含重要的安全补丁并且希望不会破坏这样做。 <code>0</code>要允许npm依赖项更新到最新的PATCH版本可以使用波形符为依赖项的版本添加前缀。在package.json中我们关于npm如何升级时刻的当前规则是仅使用特定版本2.10.2但我们希望允许最新的2.10.x版本。 <code>0</code>示例
<code>"some-package-name": "~1.3.8" allows updates to any 1.3.x version.</code> <code>0</code>指令<code>0</code>使用波形符为依赖项中的时刻版本添加前缀并允许npm将其更新为任何新的PATCH版本。 <code>0</code>请注意,不应更改版本号本身。
</section>
## Instructions
<section id='instructions'>
</section>
## Tests
<section id='tests'>
```yml
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); })'
```
</section>
## Challenge Seed
<section id='challengeSeed'>
</section>
## Solution
<section id='solution'>
```js
// solution required
```
</section>