UNPKG

clang-format-git

Version:

Node wrapper for git-clang-format Python script as a standalone native binary to allow execution without a Python dependency.🐉

25 lines (24 loc) 1.13 kB
#!/usr/bin/env node "use strict"; /** * @fileoverview Entry file for the `npx git-clang-format` or `npx clang-format-git` 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(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); } });