Skip to content

Commit bf15d06

Browse files
committed
Moving the sorting logic to store.js
1 parent 178db02 commit bf15d06

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

index.js

-7
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,6 @@ function listFolder(folder) {
1919
let filePath = path.resolve(folder, f)
2020
return !fs.lstatSync(filePath).isDirectory()
2121
})
22-
// Filter out dot files
23-
files = files.filter(f => f.indexOf('.') !== 0)
24-
25-
// Sort alphabetically in case-insensitive fashion
26-
files.sort(function (a, b) {
27-
return a.localeCompare(b);
28-
});
2922
return files
3023
}
3124

ui/arduino/store.js

+12-4
Original file line numberDiff line numberDiff line change
@@ -215,19 +215,27 @@ function store(state, emitter) {
215215
state.serialFiles = state.serialFiles.filter(
216216
f => f.indexOf('.') !== -1 // Only files with extensions
217217
)
218+
// Filter out dot files
218219
state.serialFiles = state.serialFiles.filter(
219-
f => f.indexOf('.') !== 0 // No dot files
220+
f => f.indexOf('.') !== 0
221+
)
222+
// Sort alphabetically in case-insensitive fashion
223+
state.serialFiles = state.serialFiles.sort(
224+
(a, b) => a.localeCompare(b)
220225
)
221-
state.serialFiles.sort(function (a, b) {
222-
return a.localeCompare(b);
223-
});
224226
} catch (e) {
225227
console.log('error', e)
226228
}
227229
}
228230
if (state.diskPath) {
229231
try {
230232
state.diskFiles = await disk.listFiles(state.diskPath)
233+
// Filter out dot files
234+
state.diskFiles = state.diskFiles.filter(f => f.indexOf('.') !== 0)
235+
// Sort alphabetically in case-insensitive fashion
236+
state.diskFiles = state.diskFiles.sort(
237+
(a, b) => a.localeCompare(b)
238+
)
231239
} catch (e) {
232240
console.log('error', e)
233241
}

0 commit comments

Comments
 (0)