Skip to content

Commit

Permalink
fix(plugin-version): Correctly check void releases for all falsy valu…
Browse files Browse the repository at this point in the history
…es (#1536)

js-yaml implements the YAML spec and it has no undefined type:

- nodeca/js-yaml#356 (comment)

I.e.:

```
> require('js-yaml').safeLoad('')
undefined
> require('js-yaml').safeLoad('releases:\n')
{ releases: null }
```
  • Loading branch information
martinjlowm committed Jul 5, 2020
1 parent f6f7788 commit d7ebacd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .yarn/versions/7bfd08a0.yml
@@ -0,0 +1,2 @@
releases:
"@yarnpkg/plugin-version": prerelease
5 changes: 3 additions & 2 deletions packages/plugin-version/sources/versionUtils.ts
Expand Up @@ -174,10 +174,11 @@ export async function updateVersionFiles(project: Project) {
const versionContent = await xfs.readFilePromise(versionPath, `utf8`);
const versionData = parseSyml(versionContent);

if (typeof versionData.releases === `undefined`)
const releases = versionData?.releases;
if (!releases)
continue;

for (const locatorStr of Object.keys(versionData.releases || {})) {
for (const locatorStr of Object.keys(releases)) {
const locator = structUtils.parseLocator(locatorStr);
const workspace = project.tryWorkspaceByLocator(locator);

Expand Down

0 comments on commit d7ebacd

Please sign in to comment.