« get me outta code hell

http-music - Command-line music player + utils (not a server!)
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/crawl-local.js7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/crawl-local.js b/src/crawl-local.js
index cd213e0..4c510a1 100755
--- a/src/crawl-local.js
+++ b/src/crawl-local.js
@@ -4,6 +4,7 @@
 
 const fs = require('fs')
 const path = require('path')
+const naturalSort = require('node-natural-sort')
 
 const { promisify } = require('util')
 const readDir = promisify(fs.readdir)
@@ -11,11 +12,7 @@ const stat = promisify(fs.stat)
 
 function crawl(dirPath) {
   return readDir(dirPath).then(items => {
-    items.sort((a, b) => {
-      const aUp = a.toUpperCase()
-      const bUp = b.toUpperCase()
-      return (aUp < bUp) ? -1 : (aUp == bUp) ? 0 : 1
-    })
+    items.sort(naturalSort())
 
     return Promise.all(items.map(item => {
       const itemPath = path.join(dirPath, item)