js-comments-eraser 1.1.2 → 1.1.3
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-2.js +45 -37
- package/package.json +1 -1
- package/readme.md +4 -4
package/index-multi-js-2.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
2
3
|
const path = require('path');
|
|
3
4
|
|
|
5
|
+
// const fs = require('fs');
|
|
4
6
|
const fs = require('fs-extra');
|
|
5
7
|
|
|
6
8
|
|
|
@@ -27,31 +29,18 @@ function removeCommentsFromFile(fileContent) {
|
|
|
27
29
|
// Recursive function to process files in a directory
|
|
28
30
|
function processDirectory(sourceDir, targetDir) {
|
|
29
31
|
|
|
30
|
-
// Relative path'ten absolute path'e
|
|
31
|
-
sourceDir = path.resolve(sourceDir);
|
|
32
|
-
targetDir = path.resolve(targetDir);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
// const HEDEFMEVCUT = fs.existsSync(args[1])
|
|
36
32
|
const HEDEFMEVCUT = fs.existsSync(targetDir)
|
|
37
33
|
|
|
38
|
-
// console.log(`Kaynak directory: ${sourceDir}`,`Hedef directory: ${targetDir}`);
|
|
39
|
-
|
|
40
|
-
// && path.resolve(sourceDir) === path.resolve(targetDir)
|
|
41
34
|
if (!HEDEFMEVCUT) {
|
|
42
|
-
// console.warn(`Skipping processing of target directory to avoid infinite loop: ${targetDir}`);
|
|
43
|
-
// return;
|
|
44
|
-
|
|
45
|
-
// , { recursive: false }
|
|
46
35
|
fs.mkdirSync(targetDir); // Create target directory if not exists
|
|
47
|
-
console.log(`Target directory: ${targetDir}`, "CREATED");
|
|
48
|
-
|
|
36
|
+
// console.log(`Target directory: ${targetDir}`, "CREATED");
|
|
49
37
|
}
|
|
50
38
|
|
|
51
39
|
const items = fs.readdirSync(sourceDir, { withFileTypes: true });
|
|
52
40
|
for (const item of items) {
|
|
53
41
|
const sourcePath = path.join(sourceDir, item.name);
|
|
54
42
|
const targetPath = path.join(targetDir, item.name);
|
|
43
|
+
// console.log({ sourcePath, targetPath })
|
|
55
44
|
|
|
56
45
|
if (item.isDirectory()) {
|
|
57
46
|
processDirectory(sourcePath, targetPath);
|
|
@@ -74,44 +63,63 @@ targetDir = path.resolve(targetDir);
|
|
|
74
63
|
// console.log(sourceDir, "\t\t\t->", targetPath);
|
|
75
64
|
}
|
|
76
65
|
}
|
|
66
|
+
// console.log("Bitti", { sourceDir, targetDir })
|
|
77
67
|
}
|
|
78
68
|
|
|
79
69
|
// Get command line arguments
|
|
80
70
|
const args = process.argv.slice(2);
|
|
81
71
|
|
|
72
|
+
// console.log({ args });
|
|
73
|
+
|
|
82
74
|
// if (args.length !== 2) {
|
|
83
|
-
// console.error('Usage: node js-comments-eraser <sourceDir> <targetDir>');
|
|
75
|
+
// console.error('Usage: node [your-js-comments-eraser] <sourceDir> <targetDir>');
|
|
84
76
|
// process.exit(1);
|
|
85
77
|
// }
|
|
86
78
|
if (args.length !== 1) {
|
|
87
|
-
console.error('Usage: node your-js-comments-eraser <sourceDir>');
|
|
79
|
+
console.error('Usage: node [your-js-comments-eraser] <sourceDir>');
|
|
88
80
|
process.exit(1);
|
|
89
81
|
}
|
|
90
82
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
const targetDir = "clean_dist";
|
|
83
|
+
let sourceDir = args[0]; // basit ifade
|
|
84
|
+
let targetDir = "clean_dist"; // basit ifade
|
|
94
85
|
|
|
95
|
-
console.log(
|
|
86
|
+
console.log()
|
|
87
|
+
console.log("***********************")
|
|
88
|
+
// console.log("Start processing", { sourceDir })
|
|
96
89
|
processDirectory(sourceDir, targetDir);
|
|
97
|
-
console.log(`
|
|
90
|
+
console.log(`The comment lines of all javascript files in the "${sourceDir}" folder were deleted and copied to the "${targetDir}" folder created in the same folder.`);
|
|
91
|
+
console.log("***********************")
|
|
92
|
+
|
|
98
93
|
|
|
94
|
+
const exportet = (user__dirname) => {
|
|
99
95
|
|
|
100
96
|
|
|
97
|
+
if (true) {
|
|
101
98
|
|
|
102
|
-
|
|
103
|
-
|
|
99
|
+
sourceDir = path.join(user__dirname, targetDir)//** gerçek/tam ifade */
|
|
100
|
+
targetDir = path.join(user__dirname, args[0])//** gerçek/tam ifade */
|
|
104
101
|
|
|
105
|
-
// console.log(
|
|
106
|
-
|
|
102
|
+
// console.log({ sourceDir, targetDir, user__dirname });
|
|
103
|
+
|
|
104
|
+
const finalDestination = path.join(targetDir, path.basename(sourceDir));
|
|
105
|
+
// console.log("input params", { sourceDir, targetDir })
|
|
106
|
+
// console.log("move params2", { sourceDir, finalDestination })
|
|
107
|
+
|
|
108
|
+
setTimeout(() => {
|
|
109
|
+
|
|
110
|
+
fs.move(sourceDir, finalDestination, { overwrite: true })
|
|
111
|
+
.then(() => {
|
|
112
|
+
console.log('Successfully moved.');
|
|
113
|
+
})
|
|
114
|
+
.catch(err => {
|
|
115
|
+
console.error('Some things went wrong:', err);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
}, 1);
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
}
|
|
107
124
|
|
|
108
|
-
|
|
109
|
-
fs.move(tasinacakKlasor, hedefKonum, { overwrite: true })
|
|
110
|
-
.then(() => {
|
|
111
|
-
console.log('Successfully moved.');
|
|
112
|
-
})
|
|
113
|
-
.catch(err => {
|
|
114
|
-
console.error('Some things went wrong:', err);
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
}, 1000);
|
|
125
|
+
module.exports.dirname = exportet
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -11,14 +11,14 @@ Komut satırından kullanabilmek için **yorumyok.js** gibi bir dosya açın ve
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
```
|
|
14
|
-
return require('js-comments-eraser')
|
|
14
|
+
return require('js-comments-eraser').dirname(__dirname)
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
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.
|
|
21
|
+
$ node yorumyok <kaynakDir> # 1.1.3
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
[js-comments-eraser](https://github.com/aydincandan/js-comments-eraser/pulls) için önerileriniz dikkate alınacaktır.
|
|
@@ -36,14 +36,14 @@ $ npm i js-comments-eraser
|
|
|
36
36
|
To use it from the command line, open a file like **nocomments.js** and paste the following into it.
|
|
37
37
|
|
|
38
38
|
```
|
|
39
|
-
return require('js-comments-eraser')
|
|
39
|
+
return require('js-comments-eraser').dirname(__dirname)
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
Then use it from the command line as follows.
|
|
43
43
|
|
|
44
44
|
```
|
|
45
45
|
$ node nocomments withcomments.js withoutcomments.js # 1.0.1
|
|
46
|
-
$ node nocomments <sourceDir> # 1.1.
|
|
46
|
+
$ node nocomments <sourceDir> # 1.1.3
|
|
47
47
|
|
|
48
48
|
```
|
|
49
49
|
|