50 lines
1.3 KiB
JavaScript
50 lines
1.3 KiB
JavaScript
const fs = require("node:fs");
|
|
const path = require("node:path");
|
|
|
|
const root = path.join(__dirname, "../../");
|
|
|
|
async function setupVscode() {
|
|
const vscodeDirectory = path.join(root, ".vscode/");
|
|
const settingsFile = path.join(vscodeDirectory, "settings.json");
|
|
const settingsExampleFile = path.join(
|
|
vscodeDirectory,
|
|
"settings.example.json",
|
|
);
|
|
|
|
if (fs.existsSync(settingsFile) || !fs.existsSync(settingsExampleFile)) {
|
|
return;
|
|
}
|
|
|
|
await fs.promises.copyFile(settingsExampleFile, settingsFile);
|
|
}
|
|
|
|
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}".`,
|
|
);
|
|
return;
|
|
}
|
|
|
|
await Promise.allSettled([
|
|
setupVscode(),
|
|
import("../../scripts/build-babel-code-frame-for-test.js"),
|
|
import("../../scripts/generate-flow-estree-type-definition.js"),
|
|
]);
|
|
},
|
|
},
|
|
}),
|
|
};
|