Skip to content

Commit

Permalink
feat: run Yarn command without Corepack (#202)
Browse files Browse the repository at this point in the history
* feat: run Yarn command without Corepack

* ci: run Yarn command without Corepack
  • Loading branch information
threeal authored Feb 26, 2024
1 parent e64a78a commit 4285a1b
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ jobs:

- name: Build Package
run: |
corepack yarn build
yarn build
git diff --exit-code --text HEAD
14 changes: 7 additions & 7 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ jobs:

- name: Check Format
run: |
corepack yarn format
yarn format
git diff --exit-code --text HEAD
- name: Check Lint
run: corepack yarn lint
run: yarn lint

test-package:
name: Test Package
Expand All @@ -44,7 +44,7 @@ jobs:
uses: threeal/setup-yarn-action@v1.0.0

- name: Test Package
run: corepack yarn test
run: yarn test

test-action:
name: Test Action
Expand Down Expand Up @@ -72,7 +72,7 @@ jobs:
uses: ./setup-yarn-action

- name: Build Package
run: corepack yarn pack
run: yarn pack

test-action-without-cache:
name: Test Action Without Cache
Expand Down Expand Up @@ -102,7 +102,7 @@ jobs:
cache: false

- name: Build Package
run: corepack yarn pack
run: yarn pack

test-action-with-yarn-local-cache:
name: Test Action With Yarn Local Cache
Expand All @@ -125,10 +125,10 @@ jobs:
- name: Disable Yarn Global Cache
run: |
corepack enable yarn
corepack yarn config set enableGlobalCache false
yarn config set enableGlobalCache false
- name: Setup Yarn
uses: ./setup-yarn-action

- name: Build Package
run: corepack yarn pack
run: yarn pack
4 changes: 2 additions & 2 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/yarn/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ it("should get Yarn config", async () => {

expect(getExecOutput).toHaveBeenCalledTimes(1);
expect(getExecOutput).toHaveBeenCalledWith(
"corepack",
["yarn", "config", "globalFolder", "--json"],
"yarn",
["config", "globalFolder", "--json"],
{
silent: true,
},
Expand Down
10 changes: 3 additions & 7 deletions src/yarn/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@ export { yarnInstall } from "./install.js";
export { getYarnVersion } from "./version.js";

export async function getYarnConfig(name: string): Promise<string> {
const res = await getExecOutput(
"corepack",
["yarn", "config", name, "--json"],
{
silent: true,
},
);
const res = await getExecOutput("yarn", ["config", name, "--json"], {
silent: true,
});
return JSON.parse(res.stdout).effective;
}
4 changes: 2 additions & 2 deletions src/yarn/install.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ it("should install package using Yarn", async () => {

const execCall = jest.mocked(exec).mock.calls[0];
expect(execCall).toHaveLength(3);
expect(execCall[0]).toBe("corepack");
expect(execCall[1]).toEqual(["yarn", "install", "--json"]);
expect(execCall[0]).toBe("yarn");
expect(execCall[1]).toEqual(["install", "--json"]);

expect(core.info).toHaveBeenCalledTimes(1);
expect(core.info).toHaveBeenCalledWith("YN0000: └ Completed");
Expand Down
2 changes: 1 addition & 1 deletion src/yarn/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export function printYarnInstallOutput(output: YarnInstallOutput): void {
}

export async function yarnInstall(): Promise<void> {
await exec("corepack", ["yarn", "install", "--json"], {
await exec("yarn", ["install", "--json"], {
silent: true,
listeners: {
stdline: (data) => {
Expand Down

0 comments on commit 4285a1b

Please sign in to comment.