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

npm-groovy-lint

Package Overview
Dependencies
Maintainers
1
Versions
204
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

npm-groovy-lint - npm Package Compare versions

Comparing version 10.0.1 to 10.0.2

5

CHANGELOG.md

@@ -5,2 +5,7 @@ # Changelog

## [10.0.2] 2022-08-15
- Fix error when absolute files sent as positional arguments on a linux system ([#232](https://github.com/nvuillam/npm-groovy-lint/issues/232))
- Improve performances by calculating the longest command directory to send as base path to CodeNarc
## [10.0.1] 2022-08-14

@@ -7,0 +12,0 @@

42

lib/codenarc-factory.js

@@ -5,2 +5,3 @@ // Shared functions

const debug = require("debug")("npm-groovy-lint");
const commondir = require("commondir");
const fs = require("fs-extra");

@@ -59,4 +60,7 @@ const os = require("os");

const baseBefore = (cnPath !== "." && cnPath.startsWith("/")) || cnPath.includes(":/") || cnPath.includes(":\\") ? "" : process.cwd() + "/";
result.codeNarcBaseDir = cnPath !== "." ? baseBefore + cnPath.replace(/^"(.*)"$/, "$1") : process.cwd();
result.codeNarcBaseDir = path.resolve(result.codeNarcBaseDir);
const codeNarcBaseDir = positionalArgs.length > 0 ?
(await getCodeNarcBaseDirFromFiles(positionalArgs)) :
cnPath !== "." ? baseBefore + cnPath.replace(/^"(.*)"$/, "$1") :
process.cwd();
result.codeNarcBaseDir = path.resolve(codeNarcBaseDir);
result.codenarcArgs.push(`-basedir=${result.codeNarcBaseDir}`);

@@ -95,13 +99,14 @@

}
// Absolute or cwd - relative path file
if (fs.existsSync(finalPattern)) {
// Relative with codeNarcBaseDir
else if (fs.existsSync(path.join(result.codeNarcBaseDir, finalPattern))) {
const absolutePath = path.resolve(finalPattern).replace(/\\/gu, "/");
const relativePath = path.relative(process.cwd(), path.resolve(finalPattern)).replace(/\\/gu, "/");
fileList.push(absolutePath);
const relativePath = finalPattern.replace(/\\/gu, "/");
finalPattern = "**/" + path.normalize(relativePath.replace(/[/\\]$/u, "")).replace(/\\/gu, "/");
}
// Relative with codeNardBaseDir
else if (fs.existsSync(path.join(result.codeNarcBaseDir, finalPattern))) {
const relativePath = path.relative(process.cwd(), path.join(result.codeNarcBaseDir, finalPattern)).replace(/\\/gu, "/");
fileList.push(relativePath);
// Absolute or cwd - relative path file
else if (fs.existsSync(finalPattern)) {
const absolutePath = path.resolve(finalPattern).replace(/\\/gu, "/");
fileList.push(absolutePath);
const relativePath = path.relative(result.codeNarcBaseDir, path.resolve(finalPattern)).replace(/\\/gu, "/");
finalPattern = "**/" + path.normalize(relativePath.replace(/[/\\]$/u, "")).replace(/\\/gu, "/");

@@ -180,2 +185,21 @@ }

// Calculate longest base dir by analyzing the list of files
async function getCodeNarcBaseDirFromFiles(positionalArgs) {
// All arguments are not files
if (!positionalArgs.every(fileOrDirOrPattern => fs.existsSync(fileOrDirOrPattern) || directoryExists(fileOrDirOrPattern))) {
return process.cwd()
}
const folders = positionalArgs.map((fileOrDir) => {
// Dir
if (directoryExists(fileOrDir)) {
return path.resolve(fileOrDir);
}
// File dir
const fileAbsolute = path.resolve(fileOrDir);
return path.dirname(fileAbsolute);
});
const baseDirFromFiles = commondir(folders);
return baseDirFromFiles
}
// Parse XML result file as js object

@@ -182,0 +206,0 @@ async function parseCodeNarcResult(options, codeNarcBaseDir, codeNarcJsonResult, tmpGroovyFileName, parseErrors) {

{
"name": "npm-groovy-lint",
"version": "10.0.1",
"version": "10.0.2",
"description": "Lint, format and auto-fix your Groovy / Jenkinsfile / Gradle files",

@@ -52,2 +52,3 @@ "main": "index.js",

"cli-progress": "^3.10.0",
"commondir": "^1.0.1",
"debug": "^4.1.1",

@@ -54,0 +55,0 @@ "decode-html": "^2.0.0",

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