Skip to content

Commit c9305a4

Browse files
noahnumerceyz
andauthored
fix(core): update Manifest.raw when persisting a Workspace (#2726)
* fix: reload raw manifest when persisting the manifest * test: check manifest.raw is updated Co-authored-by: merceyz <[email protected]>
1 parent e81dc0d commit c9305a4

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

.yarn/versions/bb9f6051.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
releases:
2+
"@yarnpkg/cli": patch
3+
"@yarnpkg/core": patch
4+
5+
declined:
6+
- "@yarnpkg/plugin-compat"
7+
- "@yarnpkg/plugin-constraints"
8+
- "@yarnpkg/plugin-dlx"
9+
- "@yarnpkg/plugin-essentials"
10+
- "@yarnpkg/plugin-exec"
11+
- "@yarnpkg/plugin-file"
12+
- "@yarnpkg/plugin-git"
13+
- "@yarnpkg/plugin-github"
14+
- "@yarnpkg/plugin-http"
15+
- "@yarnpkg/plugin-init"
16+
- "@yarnpkg/plugin-interactive-tools"
17+
- "@yarnpkg/plugin-link"
18+
- "@yarnpkg/plugin-node-modules"
19+
- "@yarnpkg/plugin-npm"
20+
- "@yarnpkg/plugin-npm-cli"
21+
- "@yarnpkg/plugin-pack"
22+
- "@yarnpkg/plugin-patch"
23+
- "@yarnpkg/plugin-pnp"
24+
- "@yarnpkg/plugin-stage"
25+
- "@yarnpkg/plugin-typescript"
26+
- "@yarnpkg/plugin-version"
27+
- "@yarnpkg/plugin-workspace-tools"
28+
- "@yarnpkg/builder"
29+
- "@yarnpkg/doctor"
30+
- "@yarnpkg/pnpify"

packages/yarnpkg-core/sources/Workspace.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,5 +189,7 @@ export class Workspace {
189189
await xfs.changeFilePromise(path, content, {
190190
automaticNewlines: true,
191191
});
192+
193+
this.manifest.raw = data;
192194
}
193195
}

packages/yarnpkg-core/tests/Project.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,20 @@ describe(`Project`, () => {
138138
});
139139
});
140140
});
141+
142+
it(`should update Manifest.raw when persisting a workspace`, async () => {
143+
await xfs.mktempPromise(async path => {
144+
await xfs.writeJsonPromise(ppath.join(path, Filename.manifest), {name: `foo`});
145+
await xfs.writeFilePromise(ppath.join(path, Filename.lockfile), ``);
146+
147+
const configuration = getConfiguration(path);
148+
const {project} = await Project.find(configuration, path);
149+
150+
expect(project.topLevelWorkspace.manifest.raw.main).toBeUndefined();
151+
152+
project.topLevelWorkspace.manifest.main = `./index.js` as PortablePath;
153+
await project.topLevelWorkspace.persistManifest();
154+
expect(project.topLevelWorkspace.manifest.raw.main).toEqual(`./index.js`);
155+
});
156+
});
141157
});

0 commit comments

Comments
 (0)