@bazel/buildifier
Advanced tools
Comparing version 0.29.0 to 2.2.0
#!/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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
3086
0
62
1
0
2