js-comments-eraser 1.1.4 → 1.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index-multi.js +7 -2
- package/index-single.js +1 -1
- package/package.json +10 -2
- package/readme.md +3 -2
package/index-multi.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
//KEEP: # 1.1.4
|
|
2
|
+
// https://chatgpt.com/share/67758592-d174-8011-be5b-642a87e71019
|
|
1
3
|
'use strict';
|
|
2
4
|
|
|
3
5
|
const path = require('path');
|
|
@@ -8,15 +10,18 @@ const fs = require('fs-extra');
|
|
|
8
10
|
|
|
9
11
|
// Function to remove comment lines but keep specific ones
|
|
10
12
|
function removeCommentsFromFile(fileContent) {
|
|
13
|
+
//KEEP REF: https://chatgpt.com/share/67758592-d174-8011-be5b-642a87e71019
|
|
11
14
|
const step1 = fileContent
|
|
12
15
|
.replace(/(http:\/\/)/gm, 'http:--')
|
|
13
16
|
.replace(/(https:\/\/)/gm, 'https:--'); // ilk yapılan tüm http(s) leri -- ile koruma altına alıyoruz? Nedenki sebebi?
|
|
14
17
|
|
|
15
18
|
// "KEEP" ve "gm;" etiketlerini koruyan düzenli ifade buda olması lazım //g;
|
|
16
|
-
const
|
|
19
|
+
const commentRegex = /\/\/(?!KEEP\b|gm;).*?$|\/\*(?!.*KEEP\b|gm;)[\s\S]*?\*\//gm;
|
|
20
|
+
// //g; da eklendi aşağıda.
|
|
21
|
+
const commentRegex2 = /\/\/(?!KEEP\b|gm;|g;).*?$|\/\*(?!.*KEEP\b|gm;|g;)[\s\S]*?\*\//gm;
|
|
17
22
|
|
|
18
23
|
const step2 = step1
|
|
19
|
-
.replace(
|
|
24
|
+
.replace(commentRegex2, ''); // ikinci yapılan tüm yorum satırları siliniyor iken "KEEP" ve "gm;" ve "g;" etiketleri de korunuyor.
|
|
20
25
|
|
|
21
26
|
const step3 = step2
|
|
22
27
|
.replace(/(http:--)/gm, 'http://')
|
package/index-single.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "js-comments-eraser",
|
|
3
|
-
|
|
3
|
+
"version": "1.1.6",
|
|
4
4
|
"main": "index-multi.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
@@ -19,7 +19,15 @@
|
|
|
19
19
|
"cleaner",
|
|
20
20
|
"comments"
|
|
21
21
|
],
|
|
22
|
-
"author": "aydincandan@gmail.com",
|
|
22
|
+
"author": "Aydin Candan <aydincandan@gmail.com>",
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "git+https://github.com/aydincandan/js-comments-eraser.git"
|
|
26
|
+
},
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/aydincandan/js-comments-eraser/issues"
|
|
29
|
+
},
|
|
30
|
+
"homepage": "https://github.com/aydincandan/js-comments-eraser#readme",
|
|
23
31
|
"license": "ISC",
|
|
24
32
|
"description": "It simply clears comments in all javascript files within a folder(in all sub folders[recursively]).",
|
|
25
33
|
"dependencies": {
|
package/readme.md
CHANGED
|
@@ -18,7 +18,8 @@ Daha sonra aşağıdaki gibi komut satırından kullanın.
|
|
|
18
18
|
|
|
19
19
|
```
|
|
20
20
|
$ node yorumyok yorumlu.js yorumsuz.js # 1.0.1
|
|
21
|
-
$ node yorumyok <kaynakDir> # 1.1.3
|
|
21
|
+
$ node yorumyok <kaynakDir> # >= 1.1.3
|
|
22
|
+
|
|
22
23
|
```
|
|
23
24
|
|
|
24
25
|
[js-comments-eraser](https://github.com/aydincandan/js-comments-eraser/pulls) için önerileriniz dikkate alınacaktır.
|
|
@@ -43,7 +44,7 @@ Then use it from the command line as follows.
|
|
|
43
44
|
|
|
44
45
|
```
|
|
45
46
|
$ node nocomments withcomments.js withoutcomments.js # 1.0.1
|
|
46
|
-
$ node nocomments <sourceDir> # 1.1.3
|
|
47
|
+
$ node nocomments <sourceDir> # >= 1.1.3
|
|
47
48
|
|
|
48
49
|
```
|
|
49
50
|
|