-
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: prefer bun.lockd over yarn.lock (#34)
* test: add test for `findProjectDir()` * fix: prefer bun.lockd over yarn.lock * style: format deno fmt
- Loading branch information
Showing
2 changed files
with
65 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import * as assert from "assert/strict"; | ||
import * as fs from "fs"; | ||
import * as path from "node:path"; | ||
import { runInTempDir } from "./test_utils"; | ||
import { findProjectDir } from "../src/utils"; | ||
|
||
describe("findProjectDir", () => { | ||
it("should return npm if package-lock.json is found", async () => { | ||
await runInTempDir(async (tempDir) => { | ||
await fs.promises.writeFile( | ||
path.join(tempDir, "package-lock.json"), | ||
"{}", | ||
"utf-8", | ||
); | ||
const result = await findProjectDir(tempDir); | ||
assert.strictEqual(result.pkgManagerName, "npm"); | ||
}); | ||
}); | ||
it("should return yarn if yarn.lock is found", async () => { | ||
await runInTempDir(async (tempDir) => { | ||
await fs.promises.writeFile(path.join(tempDir, "yarn.lock"), "", "utf-8"); | ||
const result = await findProjectDir(tempDir); | ||
assert.strictEqual(result.pkgManagerName, "yarn"); | ||
}); | ||
}); | ||
it("should return pnpm if pnpm-lock.yaml is found", async () => { | ||
await runInTempDir(async (tempDir) => { | ||
await fs.promises.writeFile( | ||
path.join(tempDir, "pnpm-lock.yaml"), | ||
"", | ||
"utf-8", | ||
); | ||
const result = await findProjectDir(tempDir); | ||
assert.strictEqual(result.pkgManagerName, "pnpm"); | ||
}); | ||
}); | ||
it("should return bun if bun.lockb is found", async () => { | ||
await runInTempDir(async (tempDir) => { | ||
await fs.promises.writeFile(path.join(tempDir, "bun.lockb"), "", "utf-8"); | ||
const result = await findProjectDir(tempDir); | ||
assert.strictEqual(result.pkgManagerName, "bun"); | ||
}); | ||
}); | ||
it("should return bun if bun.lockb and yarn.lock are found", async () => { | ||
// bun allow to save bun.lockb and yarn.lock | ||
// https://bun.sh/docs/install/lockfile | ||
await runInTempDir(async (tempDir) => { | ||
await fs.promises.writeFile(path.join(tempDir, "bun.lockb"), "", "utf-8"); | ||
await fs.promises.writeFile(path.join(tempDir, "yarn.lock"), "", "utf-8"); | ||
const result = await findProjectDir(tempDir); | ||
assert.strictEqual(result.pkgManagerName, "bun"); | ||
}); | ||
}); | ||
}); |