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.

55 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, "../../");
2026-02-01 08:57:18 +08:00
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;
}
fs.copyFileSync(settingsExampleFile, settingsFile);
}
async function buildBabelCodeFrameForTest() {
const { buildBabelCodeFrameForTest } =
await import("../../scripts/build-babel-code-frame-for-test.js");
await buildBabelCodeFrameForTest();
}
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-02-01 08:57:18 +08:00
setupVscode();
try {
await buildBabelCodeFrameForTest();
} catch {}
2026-02-01 08:57:18 +08:00
},
},
}),
};