cc-codeline 1.0.1 → 1.0.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.
Files changed (3) hide show
  1. package/README.md +6 -0
  2. package/bin.js +10 -11
  3. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,6 @@
1
+ # Usage is as follows
2
+ ```
3
+ npm i -g cc-codeline
4
+
5
+ codeline /path/
6
+ ```
package/bin.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  const fs = require('fs');
3
- const { join, extname } = require('path');
3
+ const { extname, resolve } = require('path');
4
4
 
5
5
  const languages = {
6
6
  '.js': {
@@ -24,6 +24,9 @@ const languages = {
24
24
  '.vue': {
25
25
  comment: /\/\*[\s\S]+?\*\/|\/\/.*|<!--[\s\S]+?-->/g
26
26
  },
27
+ '.java': {
28
+ comment: /\/\*[\s\S]+?\*\/|\/\/.*/g
29
+ },
27
30
  '.rs': {
28
31
  comment: /\/\*[\s\S]+?\*\/|\/\/.*/g
29
32
  },
@@ -40,7 +43,7 @@ const languages = {
40
43
  comment: /\/\*[\s\S]+?\*\/|\/\/.*/g
41
44
  },
42
45
  '.py': {
43
- comment: /'''[\s\S]+?'''/g
46
+ comment: /'''[\s\S]+?'''|#.*/g
44
47
  }
45
48
  };
46
49
  let total = 0;
@@ -53,7 +56,7 @@ const param = process.argv.slice(2);
53
56
  const isLog = param.includes('-l');
54
57
 
55
58
  const base = process.cwd();
56
- const path = join(base, param[0] || '');
59
+ const path = resolve(base, param[0] || '');
57
60
 
58
61
  (() => {
59
62
  if (param.includes('-h')) {
@@ -63,10 +66,6 @@ codeline /path/ -l
63
66
  -h Show help
64
67
  -l Print log
65
68
  `);
66
- // console.table({
67
- // '-h': 'Show help',
68
- // '-l': 'Print log'
69
- // });
70
69
  return;
71
70
  }
72
71
  try {
@@ -81,7 +80,7 @@ codeline /path/ -l
81
80
  });
82
81
  }
83
82
  } catch (_) {
84
- console.log('Path no found');
83
+ console.log('Error, the path may not exist');
85
84
  }
86
85
  })();
87
86
 
@@ -99,7 +98,7 @@ function readDirectory(dirPath, callback) {
99
98
  let progress = 0;
100
99
  fs.readdir(dirPath, (err, filenames) => {
101
100
  if (err) {
102
- console.log('ReadDirectory ERROR');
101
+ console.log('Error reading directory');
103
102
  callback();
104
103
  return;
105
104
  }
@@ -108,7 +107,7 @@ function readDirectory(dirPath, callback) {
108
107
  return;
109
108
  }
110
109
  for (let name of filenames) {
111
- const filepath = join(dirPath, name);
110
+ const filepath = resolve(dirPath, name);
112
111
  const fileStat = fs.statSync(filepath);
113
112
  if (fileStat.isDirectory()) {
114
113
  readDirectory(filepath, () => {
@@ -137,7 +136,7 @@ function readFile(filepath, callback) {
137
136
  }
138
137
  fs.readFile(filepath, (err, data) => {
139
138
  if (err) {
140
- console.log('ReadFile ERROR');
139
+ console.log('Error reading file');
141
140
  callback();
142
141
  return;
143
142
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cc-codeline",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "main": "bin.js",
5
5
  "description": "Quickly count your lines of code",
6
6
  "bin": {