qleaner 1.0.30 → 1.0.31
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/controllers/image.js +12 -1
- package/package.json +1 -1
package/controllers/image.js
CHANGED
|
@@ -105,14 +105,25 @@ 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 codePaths = [[`${codeDirectory}/**/*.{js,jsx,ts,tsx}`]];
|
|
108
109
|
|
|
109
110
|
// ---- Collect image files in asset directory ----
|
|
110
111
|
const imageFiles = await fg([
|
|
111
112
|
`${imageDirectory}/**/*.{png,jpg,jpeg,svg,gif,webp}`,
|
|
112
113
|
]);
|
|
113
114
|
|
|
115
|
+
if (options.excludeDir && options.excludeDir.length > 0) {
|
|
116
|
+
options.excludeDir.forEach((dir) => {
|
|
117
|
+
codePaths.push(`!${dir}/**`);
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
if (options.excludeFile && options.excludeFile.length > 0) {
|
|
121
|
+
options.excludeFile.forEach((file) => {
|
|
122
|
+
codePaths.push(`!${codeDirectory}/**/${file}`);
|
|
123
|
+
});
|
|
124
|
+
}
|
|
114
125
|
// ---- Scan Code Files ----
|
|
115
|
-
const codeFiles = await fg(
|
|
126
|
+
const codeFiles = await fg(codePaths);
|
|
116
127
|
let index = 0;
|
|
117
128
|
for (const file of codeFiles) {
|
|
118
129
|
index++;
|