diff --git a/index.ts b/index.ts index 25c1b6e..982ed80 100644 --- a/index.ts +++ b/index.ts @@ -4,6 +4,7 @@ import fs from "fs"; import path from "path"; import arg from "arg"; import invariant from "tiny-invariant"; +import console from "console"; const urlRegex = /((? 0) { - console.log(`JS link(s) found in ${filePath}:`); - console.log(jsLinks); - - if (shouldRemove) { - for (const link of jsLinks) { - fileContent = fileContent.replace(link, ""); - } - fs.writeFileSync(filePath, fileContent); - console.log(`JS link(s) removed from ${filePath}`); - } else { - console.error("Links found (use --remove to remove them)."); - } + if (jsLinks.length === 0) { + console.log(`No JS link(s) found in ${filePath}`); + return; + } + + console.log(`JS link(s) found in ${filePath}:`); + console.log(jsLinks); + + if (shouldRemove) { + jsLinks.forEach((link) => (fileContent = fileContent.replace(link, ""))); + fs.writeFileSync(filePath, fileContent); + console.log(`JS link(s) removed from ${filePath}`); + } else { + console.error("Links found (use --remove to remove them)."); } } diff --git a/package.json b/package.json index 619a282..6d3185a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "badlinks", - "version": "1.1.0", + "version": "1.1.1", "description": "A fast way to scan a package for links that might upset the chrome webstore team", "scripts": { "build": "bun run build.ts",