Files
test-repo/.yarn/plugins/plugin-prepare.cjs
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

49 lines
1.3 KiB
JavaScript
Raw Normal View History

2026-02-01 08:57:18 +08:00
const fs = require("node:fs");
const path = require("node:path");
2026-02-05 22:29:59 +08:00
const root = path.join(__dirname, "../../");
async function setupVscode() {
const vscodeDirectory = path.join(root, ".vscode/");
const settingsFile = path.join(vscodeDirectory, "settings.json");
2026-02-01 08:57:18 +08:00
const settingsExampleFile = path.join(
vscodeDirectory,
"settings.example.json",
2026-02-01 08:57:18 +08:00
);
if (fs.existsSync(settingsFile) || !fs.existsSync(settingsExampleFile)) {
return;
}
await fs.promises.copyFile(settingsExampleFile, settingsFile);
2026-02-01 08:57:18 +08:00
}
module.exports = {
name: "plugin-prepare",
factory: () => ({
hooks: {
async afterAllInstalled({ cwd: rawCwd }) {
console.log(`Yarn plugin "prepare" running in "${rawCwd}".`);
let cwd = rawCwd;
if (process.platform === "win32" && cwd.startsWith("/")) {
cwd = cwd.slice(1);
}
if (path.join(cwd, "./") !== root) {
console.log(
`Yarn plugin "prepare" skipped, yarn command not running in "${root}".`,
);
2026-02-05 22:29:59 +08:00
return;
}
2026-09-03 05:35:12 +08:00
await Promise.allSettled([
setupVscode(),
import("../../scripts/build-babel-code-frame-for-test.js"),
import("../../scripts/generate-flow-estree-type-definition.js"),
]);
2026-02-01 08:57:18 +08:00
},
},
}),
};