Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/cli.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const {spawn, execSync} = require('child_process');
const fs = require('fs');
const {join} = require('path');
const path = require('path');
const shellescape = require('any-shell-escape');
const signale = require('signale');
const parseArgs = require('./parseArgs');
Expand Down Expand Up @@ -89,7 +89,7 @@ const main = async () => {
}
}

const commitMsgFile = join(getGitDir(), 'COMMIT_EDITMSG');
const commitMsgFile = path.posix.join(getGitDir(), 'COMMIT_EDITMSG');

const command = shellescape([
'git',
Expand Down
4 changes: 1 addition & 3 deletions lib/util/getGitDir.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
const {execSync} = require('child_process');

const getGitDir = () => {
const devNull = process.platform === 'win32' ? ' nul' : '/dev/null';
const dir = execSync('git rev-parse --absolute-git-dir 2>' + devNull)
.toString()
const dir = execSync('git rev-parse --absolute-git-dir', {encoding: 'utf8'})
.trim();

return dir;
Expand Down
9 changes: 0 additions & 9 deletions test/__snapshots__/cli.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,3 @@ exports[`git-cz --help 1`] = `

"
`;

exports[`git-cz --non-interactive 1`] = `
"Running in dry mode.
Will execute command:
git commit --file '.git/COMMIT_EDITMSG'
Message:
chore: πŸ€– automated commit
"
`;
9 changes: 8 additions & 1 deletion test/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@ test('git-cz --version', async () => {
test('git-cz --non-interactive', async () => {
const {getResult} = runCLI(['--non-interactive', '--dry-run']);

const quote = process.platform === 'win32' ? '"' : '\'';
const result = await getResult();

expect(result).toMatchSnapshot();
expect(result).toBe(`\
Running in dry mode.
Will execute command:
git commit --file ${quote}.git/COMMIT_EDITMSG${quote}
Message:
chore: πŸ€– automated commit
`);
});