Skip to content

Commit acfccb3

Browse files
committed
clean up other Yarn plugins
1 parent 3c50fbd commit acfccb3

File tree

4 files changed

+19
-39
lines changed

4 files changed

+19
-39
lines changed

.yarn/plugins/boost-workaround.cjs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
* @typedef {{ configuration: Configuration; cwd: string; workspaces: Workspace[]; }} Project
66
* @typedef {{ mode?: "skip-build" | "update-lockfile"; }} InstallOptions
77
*
8-
* @type {{ name: string; factory: (require: NodeRequire) => unknown; }}
8+
* @type {{ name: string; factory: (require: NodeJS.Require) => unknown; }}
99
*/
1010
module.exports = {
1111
name: "plugin-boost-workaround",
12-
factory: (_require) => ({
12+
factory: (require) => ({
1313
hooks: {
1414
/** @type {(project: Project, options: InstallOptions) => void} */
1515
afterAllInstalled(project, options) {
@@ -25,6 +25,7 @@ module.exports = {
2525
return;
2626
}
2727

28+
const { npath } = require("@yarnpkg/fslib");
2829
const fs = require("node:fs");
2930
const path = require("node:path");
3031

@@ -33,18 +34,10 @@ module.exports = {
3334
"node_modules/react-native-macos/third-party-podspecs/boost.podspec",
3435
];
3536

36-
/**
37-
* @param {string} p
38-
* @returns {string}
39-
*/
40-
function normalize(p) {
41-
// On Windows, paths are prefixed with `/`
42-
return p.replace(/^[/\\]([^/\\]+:[/\\])/, "$1");
43-
}
44-
4537
for (const ws of project.workspaces) {
4638
for (const boostPodspec of boostPodspecs) {
47-
const podspecPath = path.join(normalize(ws.cwd), boostPodspec);
39+
const workspaceDir = npath.fromPortablePath(ws.cwd);
40+
const podspecPath = path.join(workspaceDir, boostPodspec);
4841
if (!fs.existsSync(podspecPath)) {
4942
continue;
5043
}

.yarn/plugins/link-project.cjs

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
* @typedef {{ configuration: Configuration; cwd: string; workspaces: Workspace[]; }} Project
66
* @typedef {{ mode?: "skip-build" | "update-lockfile"; }} InstallOptions
77
*
8-
* @type {{ name: string; factory: (require: NodeRequire) => unknown; }}
8+
* @type {{ name: string; factory: (require: NodeJS.Require) => unknown; }}
99
*/
1010
module.exports = {
1111
name: "plugin-link-project",
12-
factory: (_require) => ({
12+
factory: (require) => ({
1313
hooks: {
1414
/** @type {(project: Project, options: InstallOptions) => void} */
1515
afterAllInstalled(project, options) {
@@ -25,23 +25,15 @@ module.exports = {
2525
return;
2626
}
2727

28+
const { npath } = require("@yarnpkg/fslib");
2829
const fs = require("node:fs");
2930
const path = require("node:path");
3031

31-
/**
32-
* @param {string} p
33-
* @returns {string}
34-
*/
35-
function normalize(p) {
36-
// On Windows, paths are prefixed with `/`
37-
return p.replace(/^[/\\]([^/\\]+:[/\\])/, "$1");
38-
}
39-
4032
const noop = () => null;
4133
const mkdirOptions = { recursive: true, mode: 0o755 };
4234
const rmOptions = { force: true, maxRetries: 3, recursive: true };
4335

44-
const projectRoot = normalize(project.cwd);
36+
const projectRoot = npath.fromPortablePath(project.cwd);
4537
const manifestPath = path.join(projectRoot, "package.json");
4638

4739
fs.readFile(manifestPath, { encoding: "utf-8" }, (_err, manifest) => {
@@ -52,7 +44,8 @@ module.exports = {
5244
continue;
5345
}
5446

55-
const nodeModulesDir = path.join(normalize(ws.cwd), "node_modules");
47+
const workspaceDir = npath.fromPortablePath(ws.cwd);
48+
const nodeModulesDir = path.join(workspaceDir, "node_modules");
5649
const linkPath = path.join(nodeModulesDir, name);
5750

5851
fs.readlink(linkPath, (err, linkString) => {

.yarn/plugins/npm-workaround.cjs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
* @typedef {{ configuration: Configuration; cwd: string; workspaces: Workspace[]; }} Project
66
* @typedef {{ mode?: "skip-build" | "update-lockfile"; }} InstallOptions
77
*
8-
* @type {{ name: string; factory: (require: NodeRequire) => unknown; }}
8+
* @type {{ name: string; factory: (require: NodeJS.Require) => unknown; }}
99
*/
1010
module.exports = {
1111
name: "plugin-npm-workaround",
12-
factory: (_require) => ({
12+
factory: (require) => ({
1313
hooks: {
1414
/** @type {(project: Project, options: InstallOptions) => void} */
1515
afterAllInstalled(project, options) {
@@ -25,25 +25,18 @@ module.exports = {
2525
return;
2626
}
2727

28+
const { npath } = require("@yarnpkg/fslib");
2829
const fs = require("node:fs");
2930
const path = require("node:path");
3031

3132
const filesToPatch = [
3233
"node_modules/@react-native-community/cli/build/tools/npm.js",
3334
];
3435

35-
/**
36-
* @param {string} p
37-
* @returns {string}
38-
*/
39-
function normalize(p) {
40-
// On Windows, paths are prefixed with `/`
41-
return p.replace(/^[/\\]([^/\\]+:[/\\])/, "$1");
42-
}
43-
4436
for (const ws of project.workspaces) {
4537
for (const file of filesToPatch) {
46-
const jsPath = path.join(normalize(ws.cwd), file);
38+
const workspaceDir = npath.fromPortablePath(ws.cwd);
39+
const jsPath = path.join(workspaceDir, file);
4740
if (!fs.existsSync(jsPath)) {
4841
continue;
4942
}

.yarn/plugins/undo-bin-sorting.cjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ module.exports = {
2323
factory: (require) => {
2424
const { npath } = require("@yarnpkg/fslib");
2525
const fs = require("node:fs");
26+
const path = require("node:path");
2627

2728
const asText = /** @type {const} */ ({ encoding: "utf-8" });
2829

@@ -32,8 +33,8 @@ module.exports = {
3233
hooks: {
3334
/** @type {(project: Project) => void} */
3435
validateProject(project) {
35-
const pp = npath.join(project.cwd, "package.json");
36-
manifestPath = npath.fromPortablePath(pp);
36+
const projectRoot = npath.fromPortablePath(project.cwd);
37+
manifestPath = path.join(projectRoot, "package.json");
3738
orig_rawManifest = fs.readFileSync(manifestPath, asText);
3839
},
3940
/** @type {(project: Project, options: InstallOptions) => void} */

0 commit comments

Comments
 (0)