qleaner 1.0.4 → 1.0.5

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/bin/cli.js +6 -3
  2. package/command.js +14 -9
  3. package/package.json +1 -1
package/bin/cli.js CHANGED
@@ -13,9 +13,12 @@ program
13
13
  .command("qlean")
14
14
  .description("List all the imports in the project")
15
15
  .argument("<path>", "The path to the directory to scan for imports")
16
- .action(async (path) => {
17
- console.log(path);
18
- const imports = await getFiles(path);
16
+ .option("-l, --list-files", "List all the files in the project")
17
+ .option("-i, --list-imports", "List all the imports in the project")
18
+ .action(async (path, options) => {
19
+ console.log('path', path);
20
+ console.log('options', options);
21
+ const imports = await getFiles(path, options);
19
22
  });
20
23
 
21
24
 
package/command.js CHANGED
@@ -4,7 +4,7 @@ const parser = require("@babel/parser");
4
4
  const traverse = require("@babel/traverse").default;
5
5
 
6
6
 
7
- module.exports = async function getFiles(directory = "src") {
7
+ module.exports = async function getFiles(directory = "src", options) {
8
8
  const files = await fg([`${directory}/**/*.{tsx,ts,js,jsx}`]);
9
9
  const imports = [];
10
10
  for (const file of files) {
@@ -42,12 +42,17 @@ module.exports = async function getFiles(directory = "src") {
42
42
  // });
43
43
  }
44
44
 
45
- console.log('***************** Files *****************');
46
- files.forEach((file) => {
47
- console.log(file);
48
- })
49
- console.log('***************** Imports *****************');
50
- imports.forEach((importStatement) => {
51
- console.log(`${importStatement.file}:${importStatement.line}:${importStatement.column} ${importStatement.from}`);
52
- })
45
+ if (options.listFiles) {
46
+ console.log('***************** Files *****************');
47
+ files.forEach((file) => {
48
+ console.log(file);
49
+ })
50
+ }
51
+ if (options.listImports) {
52
+ console.log('***************** Imports *****************');
53
+ imports.forEach((importStatement) => {
54
+ console.log(`${importStatement.file}:${importStatement.line}:${importStatement.column} ${importStatement.from}`);
55
+ })
56
+ }
57
+
53
58
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "qleaner",
3
3
  "packageManager": "yarn@4.6.0",
4
- "version": "1.0.4",
4
+ "version": "1.0.5",
5
5
  "main": "command.js",
6
6
  "bin": "./bin/cli.js",
7
7
  "scripts": {