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

@bazel/buildifier

Package Overview
Dependencies
Maintainers
5
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bazel/buildifier - npm Package Compare versions

Comparing version 0.29.0 to 2.2.0

82

buildifier.js
#!/usr/bin/env node
// Copyright 2020 The Bazel Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
'use strict';
// This file is a shim to execute the buildifier binary from the right platform-specific package.
// This package inspired by
// https://github.com/angular/clang-format/blob/master/index.js
const os = require('os');
const fs = require('fs');
const path = require('path');
const spawnSync = require('child_process').spawnSync;
const spawn = require('child_process').spawn;
/**
* @returns the native `buildifier` binary for the current platform
* @throws when the `buildifier` executable can not be found
*/
function getNativeBinary() {
const nativePackage =
require.resolve(`@bazel/buildifier-${os.platform()}_${os.arch()}/package.json`);
if (!fs.existsSync(nativePackage)) {
const message = 'Bazel has not published a buildifier executable for your platform. ' +
`(${os.platform()}_${os.arch()})\n` +
'Consider building it from source instead.\n';
throw new Error(message);
const arch = {
'x64' : 'amd64',
}[os.arch()];
// Filter the platform based on the platforms that are build/included.
const platform = {
'darwin' : 'darwin',
'linux' : 'linux',
'win32' : 'windows',
}[os.platform()];
const extension = {
'darwin' : '',
'linux' : '',
'win32' : '.exe',
}[os.platform()];
if (arch == undefined || platform == undefined) {
console.error(`FATAL: Your platform/architecture combination ${
os.platform()} - ${os.arch()} is not yet supported.
See instructions at https://github.com/bazelbuild/buildtools/blob/master/buildifier/README.md.`);
return Promise.resolve(1);
}
const binary = JSON.parse(fs.readFileSync(nativePackage))['bin']['buildifier'];
return path.resolve(path.dirname(nativePackage), binary);
const binary =
path.join(__dirname, `buildifier-${platform}_${arch}${extension}`);
return binary;
}
/** Starts a new synchronous child process that runs buildifier with the specified arguments. */
const buildifierProcess = spawnSync(getNativeBinary(), process.argv.slice(2), {stdio: 'inherit'});
function main(args) {
const binary = getNativeBinary();
const ps = spawn(binary, args, {stdio : 'inherit'});
// Ensure that this wrapper script exits with the same exit code as the child process.
process.exit(buildifierProcess.status);
function shutdown() {
ps.kill("SIGTERM")
process.exit();
}
process.on("SIGINT", shutdown);
process.on("SIGTERM", shutdown);
ps.on('close', e => process.exitCode = e);
}
if (require.main === module) {
main(process.argv.slice(2));
}
module.exports = {
getNativeBinary,
};
{
"name": "@bazel/buildifier",
"bin": {
"buildifier": "./buildifier.js"
},
"version": "0.29.0",
"description": "A tool for formatting bazel BUILD and .bzl files with a standard convention",
"license": "Apache-2.0",
"repository": {
"type": "git",
"url": "https://github.com/bazelbuild/rules_nodejs.git",
"directory": "packages/buildifier"
},
"bugs": {
"url": "https://github.com/bazelbuild/buildtools/issues"
},
"optionalDependencies": {
"@bazel/buildifier-linux_x64": "0.29.0",
"@bazel/buildifier-darwin_x64": "0.29.0",
"@bazel/buildifier-win32_x64": "0.29.0"
}
"name": "@bazel/buildifier",
"description": "A tool for formatting bazel BUILD and .bzl files",
"version": "2.2.0",
"license": "Apache-2.0",
"bin": {
"buildifier": "buildifier.js"
},
"keywords": [
"bazel"
],
"repository": {
"type": "git",
"url": "https://github.com/bazelbuild/buildtools.git"
},
"bugs": {
"url": "https://github.com/bazelbuild/buildtools/issues"
}
}

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