-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix:
.npmrc
not written into workspace root (#73)
- Loading branch information
1 parent
5d9b0d7
commit 93b7cd4
Showing
5 changed files
with
149 additions
and
14 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 |
---|---|---|
|
@@ -101,6 +101,79 @@ describe("install", () => { | |
}); | ||
}); | ||
|
||
it("jsr i @std/encoding - inside workspace member", async () => { | ||
await runInTempDir(async (dir) => { | ||
const parentPkgJson = { name: "", private: true, workspaces: ["sub"] }; | ||
const parentPkgJsonPath = path.join(dir, "package.json"); | ||
await writeJson<PkgJson>(parentPkgJsonPath, parentPkgJson); | ||
|
||
// Create sub folder with package.json | ||
const subPkgJsonPath = path.join(dir, "sub", "package.json"); | ||
await writeJson(subPkgJsonPath, { name: "foo" }); | ||
|
||
await runJsr(["i", "@std/encoding"], path.join(dir, "sub")); | ||
|
||
assert.deepEqual( | ||
await readJson<PkgJson>(path.join(dir, "package.json")), | ||
parentPkgJson, | ||
); | ||
|
||
const pkgJson = await readJson<PkgJson>(subPkgJsonPath); | ||
assert.ok( | ||
pkgJson.dependencies && "@std/encoding" in pkgJson.dependencies, | ||
"Missing dependency entry", | ||
); | ||
|
||
assert.match( | ||
pkgJson.dependencies["@std/encoding"], | ||
/^npm:@jsr\/std__encoding@\^\d+\.\d+\.\d+.*$/, | ||
); | ||
|
||
const npmRc = await readTextFile(path.join(dir, ".npmrc")); | ||
assert.ok( | ||
npmRc.includes("@jsr:registry=https://npm.jsr.io"), | ||
"Missing npmrc registry", | ||
); | ||
}); | ||
}); | ||
|
||
it("jsr i @std/encoding - inside pnpm workspace member", async () => { | ||
await runInTempDir(async (dir) => { | ||
const parentPkgJson = { name: "", private: true }; | ||
const parentPkgJsonPath = path.join(dir, "package.json"); | ||
await writeJson<PkgJson>(parentPkgJsonPath, parentPkgJson); | ||
await writeTextFile(path.join(dir, "pnpm-workspace.yaml"), ""); | ||
|
||
// Create sub folder with package.json | ||
const subPkgJsonPath = path.join(dir, "sub", "package.json"); | ||
await writeJson(subPkgJsonPath, { name: "foo" }); | ||
|
||
await runJsr(["i", "--pnpm", "@std/encoding"], path.join(dir, "sub")); | ||
|
||
assert.deepEqual( | ||
await readJson<PkgJson>(path.join(dir, "package.json")), | ||
parentPkgJson, | ||
); | ||
|
||
const pkgJson = await readJson<PkgJson>(subPkgJsonPath); | ||
assert.ok( | ||
pkgJson.dependencies && "@std/encoding" in pkgJson.dependencies, | ||
"Missing dependency entry", | ||
); | ||
|
||
assert.match( | ||
pkgJson.dependencies["@std/encoding"], | ||
/^npm:@jsr\/std__encoding@\^\d+\.\d+\.\d+.*$/, | ||
); | ||
|
||
const npmRc = await readTextFile(path.join(dir, ".npmrc")); | ||
assert.ok( | ||
npmRc.includes("@jsr:registry=https://npm.jsr.io"), | ||
"Missing npmrc registry", | ||
); | ||
}); | ||
}); | ||
|
||
it("jsr i @std/[email protected] - with version", async () => { | ||
await withTempEnv(["i", "@std/[email protected]"], async (dir) => { | ||
const pkgJson = await readJson<PkgJson>(path.join(dir, "package.json")); | ||
|
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