https://github.com/Microsoft/TypeScript
Raw File
Tip revision: 9eb3d5a58be745121573c8efdb1b8afc2a9fbd8d authored by Anders Hejlsberg on 18 March 2023, 15:35:16 UTC
Add tests
Tip revision: 9eb3d5a
link-hooks.mjs
import fs from "fs";
import path from "path";
import url from "url";

import { findUpRoot } from "./build/findUpDir.mjs";

const __filename = url.fileURLToPath(new URL(import.meta.url));
const __dirname = path.dirname(__filename);

const hooks = [
    "post-checkout"
];

hooks.forEach((hook) => {
    const hookInSourceControl = path.resolve(__dirname, "hooks", hook);

    if (fs.existsSync(hookInSourceControl)) {
        const hookInHiddenDirectory = path.resolve(findUpRoot(), ".git", "hooks", hook);

        if (fs.existsSync(hookInHiddenDirectory)) {
            fs.unlinkSync(hookInHiddenDirectory);
        }

        fs.linkSync(hookInSourceControl, hookInHiddenDirectory);
    }
});
back to top