Skip to content

Commit

Permalink
fix window file path error
Browse files Browse the repository at this point in the history
  • Loading branch information
kokocan12 committed Jun 29, 2022
1 parent ce45097 commit 26f66c4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion __test__/meta-data-setting/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"scripts": { "postinstall": "git-commit-msg-validator" },
"dependencies": { "git-commit-msg-validator": "^1.0.4" },
"git-commit-msg-validator": "/^\\[[\\S]+\\] [\\S\\s]+\\s:\\s[\\S\\s]+/",
"devDependencies": { "git-commit-msg-validator": "^1.0.7" }
"devDependencies": { "git-commit-msg-validator": "^1.1.1" }
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "git-commit-msg-validator",
"version": "1.1.1",
"version": "1.1.2",
"description": "This is a simple git commit message validator.",
"author": "kokocan12 <dlgudwnsl1234@gmail.com>",
"license": "MIT",
Expand Down
10 changes: 5 additions & 5 deletions src/git-commit-msg-validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const prettier = require('prettier');
const START_TEXT = "# GIT_COMMIT_MSG_VALIDATOR_START";
const END_TEXT = "# GIT_COMMIT_MSG_VALIDATOR_END";
const RUN_HOOK = "./node_modules/.bin/git-commit-msg-validator-run-hook";
const VERSION = "1.1.1"
const VERSION = "1.1.2"

function getPackageJson(projectPath = process.cwd()) {
if (typeof projectPath !== "string") {
Expand Down Expand Up @@ -112,7 +112,7 @@ function getGitProjectRoot(directory=process.cwd()) {

function getCommitMsg() {
const gitRoot = getGitProjectRoot();
const commitMsgFile = gitRoot + '/' + 'COMMIT_EDITMSG';
const commitMsgFile = path.join(gitRoot, 'COMMIT_EDITMSG');

if(fs.existsSync(commitMsgFile)) {
const commitMsg = fs.readFileSync(commitMsgFile, {encoding:'utf-8'});
Expand All @@ -125,13 +125,13 @@ function getCommitMsg() {

function setHooks() {
const gitRoot = getGitProjectRoot();
const hooksDir = gitRoot + '/hooks';
const commitMsgFilePath = hooksDir + '/commit-msg';
const hooksDir = path.join(gitRoot, 'hooks');
const commitMsgFilePath = path.join(hooksDir, '/commit-msg');

const HOOK_TEXT = "\n" + START_TEXT + "\n" + RUN_HOOK + "\n" + END_TEXT + "\n";

if(fs.existsSync(commitMsgFilePath)) {
const commitMsgContent = fs.readFileSync(hooksDir + '/commit-msg', {encoding: "utf-8"});
const commitMsgContent = fs.readFileSync(commitMsgFilePath, {encoding: "utf-8"});

const startIdx = commitMsgContent.indexOf(START_TEXT);
const endIdx = commitMsgContent.indexOf(END_TEXT);
Expand Down

0 comments on commit 26f66c4

Please # to comment.