Skip to content

Commit

Permalink
fixed git hooks execution, isolate git hooks module type from reposit…
Browse files Browse the repository at this point in the history
…ory module type
  • Loading branch information
randilfernando committed Apr 15, 2024
1 parent a4e317e commit 0995f9d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cloudimpl-inc/cpm",
"version": "2.33.6",
"version": "2.33.7",
"description": "CloudImpl Project Manager",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
Expand Down
8 changes: 8 additions & 0 deletions src/git-hooks/package.json.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const packageJson = `{
"name": "hooks",
"version": "1.0.0",
"author": "Randil Fernando",
"license": "MIT"
}`

export default packageJson;
6 changes: 4 additions & 2 deletions src/plugins/flow-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import path from "path";
import {Action, CPMContext, CPMPlugin} from "../index";
import {computeIfNotExist, configFilePath, cwd, executeShellCommand, isProjectRepo, readYaml, writeYaml} from "../util";
import prepareCommitMsg from "../git-hooks/prepare-commit-msg";
import packageJson from "../git-hooks/package.json";
import chalk from 'chalk';
import inquirer from "inquirer";
import prompt = inquirer.prompt;
Expand Down Expand Up @@ -100,8 +101,9 @@ const flowSetup: Action = async (ctx, input) => {
}

if (existsSync(path.join(cwd, '.git', 'hooks'))) {
fs.writeFileSync(path.join(cwd, '.git', 'hooks', 'prepare-commit-msg'), prepareCommitMsg)
await executeShellCommand(`chmod +x ${cwd}/.git/hooks/*`)
fs.writeFileSync(path.join(cwd, '.git', 'hooks', 'package.json'), packageJson);
fs.writeFileSync(path.join(cwd, '.git', 'hooks', 'prepare-commit-msg'), prepareCommitMsg);
await executeShellCommand(`chmod +x ${cwd}/.git/hooks/*`);
}

return {};
Expand Down

0 comments on commit 0995f9d

Please sign in to comment.