Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

clang-format

Package Overview
Dependencies
Maintainers
2
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clang-format - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

25

bin/wrapper.js
#! /usr/bin/env node
// polyfill for node < 0.12
var spawnSync = require('spawn-sync');
var os = require('os');
var fs = require('fs');
var clangFormat = require('../index').spawnClangFormat;
var nativeBinary = __dirname + '/' + os.platform() + "_" + os.arch() + '/clang-format';
if (!fs.existsSync(nativeBinary)) {
process.stdout.write("FATAL: This module doesn't bundle the clang-format executable for your platform. ");
process.stdout.write("(" + os.platform() + "_" + os.arch() + ")\n");
process.stdout.write("Consider installing it with your native package manager instead.\n");
process.exit(1);
try {
clangFormat(process.argv.slice(2), process.exit, 'inherit');
} catch (e) {
process.stdout.write(e.message);
process.exit(1);
}
var result = spawnSync(nativeBinary, process.argv.slice(2));
process.stderr.write(result.stderr);
// Note, status code will always equal 0 if using busy waiting fallback
if (result.status !== 0) {
process.exit(result.status);
} else {
process.stdout.write(result.stdout);
}
var spawn = require('child_process').spawn;
var os = require('os');
var fs = require('fs');

@@ -12,20 +13,32 @@ /**

*/
function spawnClangFormat(file, enc, style, done) {
var child_process =
spawn('bin/' + os.platform() + "_" + os.arch() + '/clang-format',
['-style=' + style, file.path], {
stdio: ['ignore', 'pipe', process.stderr],
cwd: __dirname,
encoding: enc
});
function clangFormat(file, enc, style, done) {
return spawnClangFormat(['-style=' + style, file.path], done,
['ignore', 'pipe', process.stderr])
.stdout;
}
child_process.on('close', function(code) {
if (code) {
done(code);
/**
* Spawn the clang-format binary with given arguments
*/
function spawnClangFormat(args, done, stdio) {
var nativeBinary = __dirname + '/bin/' + os.platform() + "_" + os.arch() + '/clang-format';
if (!fs.existsSync(nativeBinary)) {
message = "FATAL: This module doesn't bundle the clang-format executable for your platform. " +
"(" + os.platform() + "_" + os.arch() + ")\n" +
"Consider installing it with your native package manager instead.\n";
throw new Error(message);
}
var child_process = spawn(nativeBinary, args, {
stdio: stdio,
cwd: __dirname,
});
child_process.on('close', function(exit) {
if (exit) {
done(exit);
}
});
return child_process.stdout;
return child_process;
}
module.exports = spawnClangFormat;
module.exports = clangFormat;
module.exports.spawnClangFormat = spawnClangFormat;
{
"name": "clang-format",
"version": "1.0.0",
"version": "1.0.1",
"description": "node wrapper around clang-format",

@@ -10,3 +10,2 @@ "repository": {

"main": "index.js",
"preferGlobal": "true",
"bin": {

@@ -16,6 +15,3 @@ "clang-format": "bin/wrapper.js"

"author": "Alex Eagle <alexeagle@google.com>",
"license": "Apache 2",
"dependencies": {
"spawn-sync": "^1.0.5"
}
"license": "Apache 2"
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc