From 3dd14bb9c07d8f018b3a28c11b0721fdf987ecd9 Mon Sep 17 00:00:00 2001 From: FragginWagon Date: Mon, 26 Jan 2026 22:22:27 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Standardize=20string=20quotes=20to?= =?UTF-8?q?=20single=20quotes=20and=20improve=20code=20readability?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code/utils/bookmarkletMaker.js | 48 +++++++++++++++++----------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/code/utils/bookmarkletMaker.js b/code/utils/bookmarkletMaker.js index c4ca41d..57886bf 100644 --- a/code/utils/bookmarkletMaker.js +++ b/code/utils/bookmarkletMaker.js @@ -14,10 +14,10 @@ * Example: * npm run bookmarklet -- code/bookmarklets/example-bookmarklet.js */ -import fs from "fs"; -import path from "path"; -import clipboardy from "clipboardy"; -import { fileURLToPath } from "url"; +import fs from 'fs'; +import path from 'path'; +import clipboardy from 'clipboardy'; +import { fileURLToPath } from 'url'; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); @@ -29,9 +29,9 @@ const __dirname = path.dirname(__filename); */ function removeComments(code) { // Remove multi-line comments /* ... */ - code = code.replace(/\/\*[\s\S]*?\*\//g, ""); + code = code.replace(/\/\*[\s\S]*?\*\//g, ''); // Remove single-line comments // - code = code.replace(/\/\/.*$/gm, ""); + code = code.replace(/\/\/.*$/gm, ''); return code; } @@ -42,12 +42,12 @@ function removeComments(code) { */ function minify(code) { return code - .split("\n") - .map((line) => line.trim()) - .filter((line) => line.length > 0) - .join(" ") - .replace(/\s+/g, " ") - .replace(/\s*([{}();,])\s*/g, "$1"); + .split('\n') + .map(line => line.trim()) + .filter(line => line.length > 0) + .join(' ') + .replace(/\s+/g, ' ') + .replace(/\s*([{}();,])\s*/g, '$1'); } /** @@ -62,7 +62,7 @@ function generateBookmarklet(filePath) { } // Read the JavaScript file - const jsCode = fs.readFileSync(filePath, "utf8"); + const jsCode = fs.readFileSync(filePath, 'utf8'); // Clean and minify let cleanedCode = removeComments(jsCode); @@ -79,11 +79,11 @@ try { const filePath = process.argv[2]; if (!filePath) { - console.error("āŒ Error: Please provide a file path"); - console.log("\nUsage:"); - console.log(" npm run bookmarklet -- "); - console.log("\nExample:"); - console.log(" npm run bookmarklet -- code/bookmarklets/my-bookmarklet.js"); + console.error('āŒ Error: Please provide a file path'); + console.log('\nUsage:'); + console.log(' npm run bookmarklet -- '); + console.log('\nExample:'); + console.log(' npm run bookmarklet -- code/bookmarklets/my-bookmarklet.js'); process.exit(1); } @@ -93,14 +93,14 @@ try { // Copy to clipboard clipboardy.writeSync(bookmarklet); - console.log("āœ… Bookmarklet generated successfully!"); + console.log('āœ… Bookmarklet generated successfully!'); console.log(`šŸ“ Source: ${fileName}`); console.log(`šŸ“‹ Copied to clipboard (${bookmarklet.length} characters)`); - console.log("\nšŸ“ Next steps:"); - console.log(" 1. Create a new bookmark in your browser"); - console.log(" 2. Paste the clipboard content as the URL"); - console.log(" 3. Give it a name and save"); + console.log('\nšŸ“ Next steps:'); + console.log(' 1. Create a new bookmark in your browser'); + console.log(' 2. Paste the clipboard content as the URL'); + console.log(' 3. Give it a name and save'); } catch (error) { - console.error("āŒ Error:", error.message); + console.error('āŒ Error:', error.message); process.exit(1); }