diff --git a/index-multi.js b/index-multi.js index 8f04033..f9dccd9 100644 --- a/index-multi.js +++ b/index-multi.js @@ -1,3 +1,5 @@ +//KEEP: # 1.1.4 +// https://chatgpt.com/share/67758592-d174-8011-be5b-642a87e71019 'use strict'; const path = require('path'); @@ -8,15 +10,18 @@ const fs = require('fs-extra'); // Function to remove comment lines but keep specific ones function removeCommentsFromFile(fileContent) { + //KEEP REF: https://chatgpt.com/share/67758592-d174-8011-be5b-642a87e71019 const step1 = fileContent .replace(/(http:\/\/)/gm, 'http:--') .replace(/(https:\/\/)/gm, 'https:--'); // ilk yapılan tüm http(s) leri -- ile koruma altına alıyoruz? Nedenki sebebi? // "KEEP" ve "gm;" etiketlerini koruyan düzenli ifade buda olması lazım //g; - const commentRegex = /\/\/(?!KEEP\b|gm;).*?$|\/\*(?!.*KEEP\b|gm;)[\s\S]*?\*\//gm; + const commentRegex = /\/\/(?!KEEP\b|gm;).*?$|\/\*(?!.*KEEP\b|gm;)[\s\S]*?\*\//gm; + // //g; da eklendi aşağıda. + const commentRegex2 = /\/\/(?!KEEP\b|gm;|g;).*?$|\/\*(?!.*KEEP\b|gm;|g;)[\s\S]*?\*\//gm; const step2 = step1 - .replace(/\/\/(?!KEEP\b|gm;).*?$|\/\*(?!.*KEEP\b|gm;)[\s\S]*?\*\//gm, ''); // ikinci yapılan tüm yorum satırları siliniyor iken "KEEP" ve "gm;" etiketleri de korunuyor. + .replace(commentRegex2, ''); // ikinci yapılan tüm yorum satırları siliniyor iken "KEEP" ve "gm;" ve "g;" etiketleri de korunuyor. const step3 = step2 .replace(/(http:--)/gm, 'http://') diff --git a/index-single.js b/index-single.js index 33c57eb..c3cb2f6 100644 --- a/index-single.js +++ b/index-single.js @@ -1,4 +1,4 @@ -// KEEP: # 1.0.1 +//KEEP: # 1.0.1 // https://chatgpt.com/share/67758592-d174-8011-be5b-642a87e71019 const fs = require('fs'); diff --git a/package.json b/package.json index ac4aa9e..e182afc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "js-comments-eraser", - "version": "1.1.4", + "version": "1.1.5", "main": "index-multi.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" @@ -19,7 +19,15 @@ "cleaner", "comments" ], - "author": "aydincandan@gmail.com", + "author": "Aydin Candan ", + "repository": { + "type": "git", + "url": "git+https://github.com/aydincandan/js-comments-eraser.git" + }, + "bugs": { + "url": "https://github.com/aydincandan/js-comments-eraser/issues" + }, + "homepage": "https://github.com/aydincandan/js-comments-eraser#readme", "license": "ISC", "description": "It simply clears comments in all javascript files within a folder(in all sub folders[recursively]).", "dependencies": {