New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

create-mithrilts-app

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

create-mithrilts-app - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

89

bin/index.js

@@ -27,49 +27,52 @@ #! /usr/bin/env node

function replaceWordsInFiles(folderPath, dictionary) {
fs.readdir(folderPath, (err, files) => {
if (err) {
console.error("Error reading folder:", err);
return;
}
async function replaceWordsInFiles(folderPath, dictionary) {
return new Promise((resolve) => {
fs.readdir(folderPath, (err, files) => {
if (err) {
console.error("Error reading folder:", err);
return;
}
files.forEach((file) => {
const filePath = path.join(folderPath, file);
fs.stat(filePath, (err, stats) => {
if (err) {
console.error("Error getting file stats:", err);
return;
}
if (
stats.isFile() &&
(file.endsWith(".ts") || file.endsWith(".json"))
) {
fs.readFile(filePath, "utf8", (err, data) => {
if (err) {
console.error("Error reading file:", err);
return;
}
files.forEach((file) => {
const filePath = path.join(folderPath, file);
fs.stat(filePath, async (err, stats) => {
if (err) {
console.error("Error getting file stats:", err);
return;
}
if (
stats.isFile() &&
(file.endsWith(".ts") || file.endsWith(".json"))
) {
fs.readFile(filePath, "utf8", (err, data) => {
if (err) {
console.error("Error reading file:", err);
return;
}
// Replace words in the file content using the dictionary
let replacedContent = data;
for (const [key, value] of dictionary.entries()) {
const regex = new RegExp("\\b" + key + "\\b", "g"); // word boundary
replacedContent = replacedContent.replace(regex, value);
}
// Replace words in the file content using the dictionary
let replacedContent = data;
for (const [key, value] of dictionary.entries()) {
const regex = new RegExp("\\b" + key + "\\b", "g"); // word boundary
replacedContent = replacedContent.replace(regex, value);
}
// Write the modified content back to the file
if (data !== replacedContent) {
fs.writeFile(filePath, replacedContent, "utf8", (err) => {
if (err) {
console.error("Error writing file:", err);
} else {
console.log(`Words replaced in file: ${filePath}`);
}
});
}
});
} else if (stats.isDirectory()) {
// Recursively process subfolders
replaceWordsInFiles(filePath, dictionary);
}
// Write the modified content back to the file
if (data !== replacedContent) {
fs.writeFile(filePath, replacedContent, "utf8", (err) => {
if (err) {
console.error("Error writing file:", err);
} else {
console.log(`Words replaced in file: ${filePath}`);
}
});
}
});
} else if (stats.isDirectory()) {
// Recursively process subfolders
await replaceWordsInFiles(filePath, dictionary);
}
});
});
resolve();
});

@@ -76,0 +79,0 @@ });

{
"name": "create-mithrilts-app",
"version": "1.0.0",
"version": "1.0.1",
"description": "Create a mithril app, using TypeScript and Materialize-CSS.",

@@ -5,0 +5,0 @@ "main": "bin/index.js",

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