Skip to content

Commit e6509b6

Browse files
authored
Merge pull request #39 from arduino/file-sorting
fixed disk files sorting. updated .gitignore
2 parents b15464b + bf15d06 commit e6509b6

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ dist
55
.history
66
dist/
77
.vscode
8+
.npmrc
89
Resources
910
temp

index.js

-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +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)
2422
return files
2523
}
2624

ui/arduino/store.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,13 @@ 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
)
221226
} catch (e) {
222227
console.log('error', e)
@@ -225,6 +230,12 @@ function store(state, emitter) {
225230
if (state.diskPath) {
226231
try {
227232
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+
)
228239
} catch (e) {
229240
console.log('error', e)
230241
}

0 commit comments

Comments
 (0)