bimmo-cli 4.0.5 → 4.0.6
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/package.json +1 -1
- package/src/interface.js +19 -8
package/package.json
CHANGED
package/src/interface.js
CHANGED
|
@@ -152,15 +152,26 @@ const BimmoApp = ({ initialConfig }) => {
|
|
|
152
152
|
const dir = p.includes('/') ? p.substring(0, p.lastIndexOf('/')) : '.';
|
|
153
153
|
const filter = p.includes('/') ? p.substring(p.lastIndexOf('/') + 1) : p;
|
|
154
154
|
const absDir = path.resolve(process.cwd(), dir);
|
|
155
|
-
if (!fs.existsSync(absDir)) return [];
|
|
156
|
-
|
|
155
|
+
if (!fs.existsSync(absDir) || !fs.statSync(absDir).isDirectory()) return [];
|
|
156
|
+
|
|
157
|
+
const files = fs.readdirSync(absDir)
|
|
157
158
|
.filter(f => f.startsWith(filter) && !f.startsWith('.') && f !== 'node_modules')
|
|
158
|
-
.
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
159
|
+
.map(f => {
|
|
160
|
+
const fullPath = path.join(absDir, f);
|
|
161
|
+
const isDir = fs.statSync(fullPath).isDirectory();
|
|
162
|
+
return {
|
|
163
|
+
name: f,
|
|
164
|
+
isDir,
|
|
165
|
+
rel: path.join(dir === '.' ? '' : dir, f)
|
|
166
|
+
};
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
// Ordena: pastas primeiro, depois arquivos
|
|
170
|
+
return files.sort((a, b) => {
|
|
171
|
+
if (a.isDir && !b.isDir) return -1;
|
|
172
|
+
if (!a.isDir && b.isDir) return 1;
|
|
173
|
+
return a.name.localeCompare(b.name);
|
|
174
|
+
}).slice(0, 10);
|
|
164
175
|
} catch (e) { return []; }
|
|
165
176
|
}, [input]);
|
|
166
177
|
|