js-comments-eraser 1.1.1 → 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.
@@ -1,6 +1,8 @@
1
- // const fs = require('fs');
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
 
@@ -26,29 +28,19 @@ function removeCommentsFromFile(fileContent) {
26
28
 
27
29
  // Recursive function to process files in a directory
28
30
  function processDirectory(sourceDir, targetDir) {
29
- // const sourceDir = args[0];
30
- // const targetDir = args[1];
31
31
 
32
- // const HEDEFMEVCUT = fs.existsSync(args[1])
33
32
  const HEDEFMEVCUT = fs.existsSync(targetDir)
34
33
 
35
- // console.log(`Kaynak directory: ${sourceDir}`,`Hedef directory: ${targetDir}`);
36
-
37
- // && path.resolve(sourceDir) === path.resolve(targetDir)
38
34
  if (!HEDEFMEVCUT) {
39
- // console.warn(`Skipping processing of target directory to avoid infinite loop: ${targetDir}`);
40
- // return;
41
-
42
- // , { recursive: false }
43
35
  fs.mkdirSync(targetDir); // Create target directory if not exists
44
- console.log(`Target directory: ${targetDir}`, "CREATED");
45
-
36
+ // console.log(`Target directory: ${targetDir}`, "CREATED");
46
37
  }
47
38
 
48
39
  const items = fs.readdirSync(sourceDir, { withFileTypes: true });
49
40
  for (const item of items) {
50
41
  const sourcePath = path.join(sourceDir, item.name);
51
42
  const targetPath = path.join(targetDir, item.name);
43
+ // console.log({ sourcePath, targetPath })
52
44
 
53
45
  if (item.isDirectory()) {
54
46
  processDirectory(sourcePath, targetPath);
@@ -71,44 +63,63 @@ function processDirectory(sourceDir, targetDir) {
71
63
  // console.log(sourceDir, "\t\t\t->", targetPath);
72
64
  }
73
65
  }
66
+ // console.log("Bitti", { sourceDir, targetDir })
74
67
  }
75
68
 
76
69
  // Get command line arguments
77
70
  const args = process.argv.slice(2);
78
71
 
72
+ // console.log({ args });
73
+
79
74
  // if (args.length !== 2) {
80
- // console.error('Usage: node js-comments-eraser <sourceDir> <targetDir>');
75
+ // console.error('Usage: node [your-js-comments-eraser] <sourceDir> <targetDir>');
81
76
  // process.exit(1);
82
77
  // }
83
78
  if (args.length !== 1) {
84
- console.error('Usage: node your-js-comments-eraser <sourceDir>');
79
+ console.error('Usage: node [your-js-comments-eraser] <sourceDir>');
85
80
  process.exit(1);
86
81
  }
87
82
 
88
- const sourceDir = args[0];
89
- // const targetDir = args[1];
90
- const targetDir = "clean_dist";
83
+ let sourceDir = args[0]; // basit ifade
84
+ let targetDir = "clean_dist"; // basit ifade
91
85
 
92
- console.log("Start processing")
86
+ console.log()
87
+ console.log("***********************")
88
+ // console.log("Start processing", { sourceDir })
93
89
  processDirectory(sourceDir, targetDir);
94
- console.log(`All .js files from ${sourceDir} have been processed and saved to ${sourceDir}/${targetDir}.`);
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
+
93
+
94
+ const exportet = (user__dirname) => {
95
95
 
96
96
 
97
+ if (true) {
97
98
 
99
+ sourceDir = path.join(user__dirname, targetDir)//** gerçek/tam ifade */
100
+ targetDir = path.join(user__dirname, args[0])//** gerçek/tam ifade */
98
101
 
99
- const tasinacakKlasor = path.join(__dirname, targetDir); // Taşınacak klasör
100
- const hedefKonum = path.join(__dirname, sourceDir); // Hedef konum
102
+ // console.log({ sourceDir, targetDir, user__dirname });
101
103
 
102
- // console.log(tasinacakKlasor)
103
- // console.log(hedefKonum)
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
+ }
104
124
 
105
- setTimeout(() => {
106
- fs.move(tasinacakKlasor, hedefKonum, { overwrite: true })
107
- .then(() => {
108
- console.log('Successfully moved.');
109
- })
110
- .catch(err => {
111
- console.error('Some things went wrong:', err);
112
- });
113
-
114
- }, 1000);
125
+ module.exports.dirname = exportet
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js-comments-eraser",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "main": "index-multi-js-2.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
package/readme.md CHANGED
@@ -1,6 +1,4 @@
1
1
 
2
- # DONT USE 1.1.0 version Some things went wrong
3
-
4
2
  ## Türkçe
5
3
 
6
4
  Projenize dahil etmek için aşağıdaki gibi yapın.
@@ -13,14 +11,14 @@ Komut satırından kullanabilmek için **yorumyok.js** gibi bir dosya açın ve
13
11
 
14
12
 
15
13
  ```
16
- return require('js-comments-eraser')
14
+ return require('js-comments-eraser').dirname(__dirname)
17
15
  ```
18
16
 
19
17
  Daha sonra aşağıdaki gibi komut satırından kullanın.
20
18
 
21
19
  ```
22
20
  $ node yorumyok yorumlu.js yorumsuz.js # 1.0.1
23
- $ node yorumyok <kaynakDir> # 1.1.0
21
+ $ node yorumyok <kaynakDir> # 1.1.3
24
22
  ```
25
23
 
26
24
  [js-comments-eraser](https://github.com/aydincandan/js-comments-eraser/pulls) için önerileriniz dikkate alınacaktır.
@@ -38,14 +36,14 @@ $ npm i js-comments-eraser
38
36
  To use it from the command line, open a file like **nocomments.js** and paste the following into it.
39
37
 
40
38
  ```
41
- return require('js-comments-eraser')
39
+ return require('js-comments-eraser').dirname(__dirname)
42
40
  ```
43
41
 
44
42
  Then use it from the command line as follows.
45
43
 
46
44
  ```
47
45
  $ node nocomments withcomments.js withoutcomments.js # 1.0.1
48
- $ node nocomments <sourceDir> # 1.1.0
46
+ $ node nocomments <sourceDir> # 1.1.3
49
47
 
50
48
  ```
51
49