diff options
| author | pack <pack@packgekko.xyz> | 2026-08-09 10:54:08 +0000 |
|---|---|---|
| committer | pack <pack@packgekko.xyz> | 2026-08-09 10:54:08 +0000 |
| commit | d3adc16a08d95d6e331de55d7d3bf05a66a874a8 (patch) | |
| tree | a2dabd199501e67c547c2ce79e1374ca3aa55443 /node_modules/node-addon-api/tools/clang-format.js | |
| parent | 55a4f1fc869e41aca748c63d3018f0448b1606e0 (diff) | |
| download | crud-d3adc16a08d95d6e331de55d7d3bf05a66a874a8.tar.gz | |
stop tracking node_modules/
Diffstat (limited to 'node_modules/node-addon-api/tools/clang-format.js')
| -rw-r--r-- | node_modules/node-addon-api/tools/clang-format.js | 71 |
1 files changed, 0 insertions, 71 deletions
diff --git a/node_modules/node-addon-api/tools/clang-format.js b/node_modules/node-addon-api/tools/clang-format.js deleted file mode 100644 index e4bb4f5..0000000 --- a/node_modules/node-addon-api/tools/clang-format.js +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/env node - -const spawn = require('child_process').spawnSync; -const path = require('path'); - -const filesToCheck = ['*.h', '*.cc']; -const FORMAT_START = process.env.FORMAT_START || 'main'; - -function main (args) { - let fix = false; - while (args.length > 0) { - switch (args[0]) { - case '-f': - case '--fix': - fix = true; - break; - default: - } - args.shift(); - } - - const clangFormatPath = path.dirname(require.resolve('clang-format')); - const binary = process.platform === 'win32' - ? 'node_modules\\.bin\\clang-format.cmd' - : 'node_modules/.bin/clang-format'; - const options = ['--binary=' + binary, '--style=file']; - if (fix) { - options.push(FORMAT_START); - } else { - options.push('--diff', FORMAT_START); - } - - const gitClangFormatPath = path.join(clangFormatPath, 'bin/git-clang-format'); - const result = spawn( - 'python', - [gitClangFormatPath, ...options, '--', ...filesToCheck], - { encoding: 'utf-8' } - ); - - if (result.stderr) { - console.error('Error running git-clang-format:', result.stderr); - return 2; - } - - const clangFormatOutput = result.stdout.trim(); - // Bail fast if in fix mode. - if (fix) { - console.log(clangFormatOutput); - return 0; - } - // Detect if there is any complains from clang-format - if ( - clangFormatOutput !== '' && - clangFormatOutput !== 'no modified files to format' && - clangFormatOutput !== 'clang-format did not modify any files' - ) { - console.error(clangFormatOutput); - const fixCmd = 'npm run lint:fix'; - console.error(` - ERROR: please run "${fixCmd}" to format changes in your commit - Note that when running the command locally, please keep your local - main branch and working branch up to date with nodejs/node-addon-api - to exclude un-related complains. - Or you can run "env FORMAT_START=upstream/main ${fixCmd}".`); - return 1; - } -} - -if (require.main === module) { - process.exitCode = main(process.argv.slice(2)); -} |