Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a288ad2

Browse files
committed
fix issues found when running check-clang-format from another repo
1 parent 809dbf7 commit a288ad2

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

bin/check-clang-format.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
*/
1212

1313
const spawn = require('child_process').spawnSync;
14+
const path = require('path');
1415

1516
function checkGitConfig() {
1617
const spawn_opts = {encoding: 'utf-8', stdio: ['pipe', 'pipe', 'inherit']};
@@ -42,12 +43,14 @@ function checkGitConfig() {
4243
$ git config clangFormat.style file`);
4344
return 2;
4445
}
46+
return 0;
4547
}
4648

4749
function main(args) {
4850
try {
49-
var clangFormatPath = require.resolve('clang-format');
51+
var clangFormatPath = path.dirname(require.resolve('clang-format'));
5052
var configCheck = checkGitConfig();
53+
5154
if (configCheck !== 0) return configCheck;
5255
} catch (e) {
5356
// When running the git-clang-format on ourselves, it's located in a
@@ -57,8 +60,7 @@ function main(args) {
5760
// in a different place
5861
}
5962

60-
const gitClangFormatPath =
61-
require('path').relative(clangFormatPath, 'bin/git-clang-format');
63+
const gitClangFormatPath = path.join(clangFormatPath, 'bin/git-clang-format');
6264
const result = spawn(gitClangFormatPath, ['--diff'], {encoding: 'utf-8'});
6365

6466
if (result.error) {

0 commit comments

Comments
 (0)