This repository has been archived on 2020-11-02. You can view files and clone it, but cannot push or open issues or pull requests.
TripSit_Suite/node_modules/husky/lib/installer/mainScript.js

26 lines
986 B
JavaScript
Raw Normal View History

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const fs = require("fs");
const path = require("path");
const getBanner_1 = require("./getBanner");
const read_pkg_1 = require("../read-pkg");
function getMainScript() {
const pkg = read_pkg_1.readPkg(path.join(__dirname, '../..'));
const mainScript = fs
.readFileSync(path.join(__dirname, '../../sh/husky.sh'), 'utf-8')
.replace('huskyVersion="0.0.0"', `huskyVersion="${pkg.version}"`);
return [getBanner_1.getBanner(), '', mainScript].join('\n');
}
exports.getMainScript = getMainScript;
function createMainScript(gitHooksDir) {
fs.writeFileSync(path.join(gitHooksDir, 'husky.sh'), getMainScript(), 'utf-8');
}
exports.createMainScript = createMainScript;
function removeMainScript(gitHooksDir) {
const filename = path.join(gitHooksDir, 'husky.sh');
if (fs.existsSync(filename)) {
fs.unlinkSync(filename);
}
}
exports.removeMainScript = removeMainScript;