clang-format-git-python
Version:
Node wrapper for git-clang-format Python script. This package requires Python3 as a dependency.🐉
30 lines (29 loc) • 1.49 kB
JavaScript
;
/**
* @fileoverview Entry file for the `npx git-clang-format` or `npx clang-format-git-python` command. See the `bin` property in `package.json`.
*/
/* eslint-disable n/prefer-node-protocol -- DO NOT USE `node:` namespace for backward compatibility */
// --------------------------------------------------------------------------------
// Require
// --------------------------------------------------------------------------------
const { spawn } = require('child_process');
const { clangFormatPath } = require('clang-format-node');
const { gitClangFormatPath } = require('./utils/gitClangFormatPath');
// --------------------------------------------------------------------------------
// Execution
// --------------------------------------------------------------------------------
const spawned = spawn('python',
// Both `--binary=path/to/the/binary` and `--binary path/to/the/binary` commands are valid (the only difference is the `=`).
//
// If you pass a `--binary` argument like `npx git-clang-format-python --binary="path/to/the/binary"` in bash,
// the `--binary="path/to/the/binary"` argument will override the current `--binary=${clangFormatPath}` code.
[gitClangFormatPath, `--binary=${clangFormatPath}`, ...process.argv.slice(2)], {
stdio: 'inherit',
});
spawned.on('close', code => {
if (code !== 0) {
console.error(`Process exited with code: ${code}`); // eslint-disable-line no-console
process.exit(code);
}
});