qleaner 1.0.32 → 1.0.34

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/bin/cli.js CHANGED
@@ -75,7 +75,7 @@ async function loadChalk() {
75
75
  )
76
76
  .option("-t, --table", "Print the results in a table")
77
77
  .option("-d, --dry-run", "Show what would be deleted without actually deleting (skips prompt)")
78
- .option("-C, --clear-cache", "Clear the cache recommended after making code changes")
78
+ // .option("-C, --clear-cache", "Clear the cache recommended after making code changes")
79
79
  .action(async (directory, rootPath, options) => {
80
80
  await getUnusedImages(chalk, directory, rootPath, options);
81
81
  });
@@ -105,20 +105,29 @@ function extractFromJSXStyle(node, file, collected) {
105
105
  async function getUnusedImages(chalk, imageDirectory, codeDirectory, options) {
106
106
  const used = new Set();
107
107
  const unusedImages = [];
108
+ const imagePaths = [`${imageDirectory}/**/*.{png,jpg,jpeg,svg,gif,webp}`];
108
109
  const codePaths = [`${codeDirectory}/**/*.{js,jsx,ts,tsx}`];
109
110
 
111
+ if (options.excludeDirAssets && options.excludeDirAssets.length > 0) {
112
+ options.excludeDirAssets.forEach((dir) => {
113
+ imagePaths.push(`!${dir}/**`);
114
+ });
115
+ }
116
+ if (options.excludeFileAssets && options.excludeFileAssets.length > 0) {
117
+ options.excludeFileAssets.forEach((file) => {
118
+ imagePaths.push(`!${imageDirectory}/**/${file}`);
119
+ });
120
+ }
110
121
  // ---- Collect image files in asset directory ----
111
- const imageFiles = await fg([
112
- `${imageDirectory}/**/*.{png,jpg,jpeg,svg,gif,webp}`,
113
- ]);
122
+ const imageFiles = await fg(imagePaths);
114
123
 
115
- if (options.excludeDir && options.excludeDir.length > 0) {
116
- options.excludeDir.forEach((dir) => {
124
+ if (options.excludeDirCode && options.excludeDirCode.length > 0) {
125
+ options.excludeDirCode.forEach((dir) => {
117
126
  codePaths.push(`!${dir}/**`);
118
127
  });
119
128
  }
120
- if (options.excludeFile && options.excludeFile.length > 0) {
121
- options.excludeFile.forEach((file) => {
129
+ if (options.excludeFileCode && options.excludeFileCode.length > 0) {
130
+ options.excludeFileCode.forEach((file) => {
122
131
  codePaths.push(`!${codeDirectory}/**/${file}`);
123
132
  });
124
133
  }
package/package.json CHANGED
@@ -1,13 +1,15 @@
1
1
  {
2
2
  "name": "qleaner",
3
3
  "packageManager": "yarn@4.6.0",
4
- "version": "1.0.32",
4
+ "version": "1.0.34",
5
5
  "license": "MIT",
6
6
  "main": "command.js",
7
- "bin": "./bin/cli.js",
7
+ "bin": {
8
+ "qleaner": "bin/cli.js"
9
+ },
8
10
  "repository": {
9
11
  "type": "git",
10
- "url": "git@github.com:trevismurithi/react-cleaner.git"
12
+ "url": "git+ssh://git@github.com/trevismurithi/react-cleaner.git"
11
13
  },
12
14
  "bugs": {
13
15
  "url": "https://github.com/trevismurithi/react-cleaner/issues"
@@ -28,7 +28,7 @@ async function getCssImages(directory = "src") {
28
28
  let index = 0;
29
29
  for (const file of cssFiles) {
30
30
  index++;
31
- console.clear();
31
+ //console.clear();
32
32
  console.log('Scanning CSS files...', index, 'of', cssFiles.length);
33
33
  const css = fs.readFileSync(file, "utf-8");
34
34
  images = extractCssImages(css, images, file);