Socket
Socket
Sign inDemoInstall

css-absolute-values-to-px

Package Overview
Dependencies
1
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.8 to 1.0.10

2

package.json
{
"name": "css-absolute-values-to-px",
"version": "1.0.8",
"version": "1.0.10",
"main": "index.js",

@@ -5,0 +5,0 @@ "author": "https://github.com/omateusanjos",

@@ -7,16 +7,10 @@ const fs = require("fs").promises;

const fileContent = await fs.readFile(filePath, "utf8");
const convertedContent = fileContent.replace(
/(-?\b\d+(?:\.\d+)?\b)(?![\s\S]*["'])(?=[,;])/g,
(_, value) => {
// Check if the value is already wrapped in double quotes
if (value.startsWith('"') && value.endsWith('"')) {
return value;
} else {
return `"${value}px"`;
}
}
);
const modifiedContent = transformJavaScriptObjects(fileContent);
await fs.writeFile(filePath, convertedContent);
console.log(`File update: ${filePath}`);
if (fileContent === modifiedContent) {
return console.log(`File skipped: ${filePath}. Please, open a issue.`);
}
await fs.writeFile(filePath, modifiedContent);
console.log(`File updated: ${filePath}`);
} catch (error) {

@@ -27,2 +21,13 @@ console.error(`Error converting ${filePath}: ${error}`);

function transformJavaScriptObjects(fileContent) {
const objectPattern = /({[^{}]*})/g;
return fileContent.replace(objectPattern, (match) => {
return match.replace(
/(-?\b\d+\b)(?![\s\S]*["'])(?=:|\s*[;,}])/g,
(_, value) => `"${value}px"`
);
});
}
async function processDirectory(

@@ -29,0 +34,0 @@ directoryPath,

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc