Skip to content

Commit 251b811

Browse files
committed
fix(yarn): use yarn CLI to set nodeLinker
1 parent dbd2179 commit 251b811

File tree

1 file changed

+5
-34
lines changed

1 file changed

+5
-34
lines changed

yarn/set-linker-to-node-modules.ts

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,18 @@
1-
import {map} from "@softwareventures/array";
2-
import type {Document} from "yaml";
31
import type {ProjectSource} from "../project/project.js";
42
import type {Result} from "../result/result.js";
5-
import {bindAsyncResultFn, bindFailureFn, failure, mapResultFn} from "../result/result.js";
6-
import type {ReadYamlFailureReason} from "../project/read-yaml.js";
7-
import {readProjectYamlAsDocument} from "../project/read-yaml.js";
8-
import type {WriteYamlFailureReason} from "../project/write-yaml.js";
9-
import {writeProjectYaml} from "../project/write-yaml.js";
3+
import {mapFailureFn} from "../result/result.js";
4+
import {yarn} from "./yarn.js";
105

116
export type SetYarnLinkerResult = Result<SetYarnLinkerFailureReason>;
127

138
export interface SetYarnLinkerFailureReason {
149
readonly type: "set-yarn-linker-failed";
15-
readonly reason: ReadYamlFailureReason | WriteYamlFailureReason;
1610
}
1711

1812
export async function setYarnLinkerToNodeModules(
1913
project: ProjectSource
2014
): Promise<SetYarnLinkerResult> {
21-
return readProjectYamlAsDocument(project, ".yarnrc.yml")
22-
.then(
23-
mapResultFn(document => {
24-
document.set("nodeLinker", "node-modules");
25-
return document;
26-
})
27-
)
28-
.then(
29-
bindAsyncResultFn<ReadYamlFailureReason, WriteYamlFailureReason, Document.Parsed>(
30-
async document => writeProjectYaml(project, ".yarnrc.yml", document)
31-
)
32-
)
33-
.then(
34-
bindFailureFn(reasons =>
35-
failure(
36-
map(
37-
reasons,
38-
reason =>
39-
({
40-
type: "set-yarn-linker-failed",
41-
reason
42-
}) as const
43-
)
44-
)
45-
)
46-
);
15+
return yarn(project, "config", "set", "nodeLinker", "node-modules").then(
16+
mapFailureFn(() => ({type: "set-yarn-linker-failed"}) as const)
17+
);
4718
}

0 commit comments

Comments
 (0)