-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(use): create
package.json
when calling corepack use
on empty …
…dir (#350) Co-authored-by: Maël Nison <[email protected]>
- Loading branch information
Showing
8 changed files
with
44 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ describe(`UseCommand`, () => { | |
it(`should set the package manager in the current project`, async () => { | ||
await xfs.mktempPromise(async cwd => { | ||
await xfs.writeJsonPromise(ppath.join(cwd, `package.json`), { | ||
packageManager: `[email protected]`, | ||
}); | ||
|
||
await expect(runCli(cwd, [`use`, `[email protected]`])).resolves.toMatchObject({ | ||
|
@@ -29,4 +30,37 @@ describe(`UseCommand`, () => { | |
}); | ||
}); | ||
}); | ||
|
||
it(`should create a package.json if absent`, async () => { | ||
await xfs.mktempPromise(async cwd => { | ||
await expect(runCli(cwd, [`use`, `[email protected]`])).resolves.toMatchObject({ | ||
exitCode: 0, | ||
stderr: `warning package.json: No license field\nwarning No license field\n`, | ||
}); | ||
|
||
await expect(xfs.readJsonPromise(ppath.join(cwd, `package.json`))).resolves.toMatchObject({ | ||
packageManager: `[email protected]+sha256.bc5316aa110b2f564a71a3d6e235be55b98714660870c5b6b2d2d3f12587fb58`, | ||
}); | ||
|
||
await expect(runCli(cwd, [`yarn`, `--version`])).resolves.toMatchObject({ | ||
exitCode: 0, | ||
stdout: `1.22.4\n`, | ||
stderr: ``, | ||
}); | ||
|
||
// Ensure Corepack is able to detect package.json in parent directory | ||
const subfolder = ppath.join(cwd, `subfolder`); | ||
await xfs.mkdirPromise(subfolder); | ||
|
||
await expect(runCli(subfolder, [`use`, `[email protected]`])).resolves.toMatchObject({ | ||
exitCode: 0, | ||
stderr: ``, | ||
}); | ||
await expect(runCli(cwd, [`yarn`, `--version`])).resolves.toMatchObject({ | ||
exitCode: 0, | ||
stdout: `2.2.2\n`, | ||
stderr: ``, | ||
}); | ||
}); | ||
}); | ||
}); |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.