From ba828b4f12779c1ce356ea2c0d99bcb891a09aa0 Mon Sep 17 00:00:00 2001 From: Florrie Date: Fri, 17 Jul 2020 19:02:18 -0300 Subject: use better package for natural sorting --- crawlers.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'crawlers.js') diff --git a/crawlers.js b/crawlers.js index e39dfa1..3f6e391 100644 --- a/crawlers.js +++ b/crawlers.js @@ -1,11 +1,11 @@ const fs = require('fs') const path = require('path') -const naturalSort = require('node-natural-sort') const expandHomeDir = require('expand-home-dir') const fetch = require('node-fetch') const url = require('url') const { downloadPlaylistFromOptionValue, promisifyProcess } = require('./general-util') const { spawn } = require('child_process') +const { orderBy } = require('natural-orderby') const { promisify } = require('util') const readDir = promisify(fs.readdir) @@ -20,12 +20,6 @@ const stat = promisify(fs.stat) // getAllCrawlersForArg. const allCrawlers = {} -function sortIgnoreCase(sortFunction) { - return function(a, b) { - return sortFunction(a.toLowerCase(), b.toLowerCase()) - } -} - /* TODO: Removed cheerio, so crawl-http no longer works. function crawlHTTP(absURL, opts = {}, internals = {}) { // Recursively crawls a given URL, following every link to a deeper path and @@ -254,7 +248,7 @@ function crawlLocal(dirPath, extensions = [ } return readDir(dirPath).then(items => { - items.sort(sortIgnoreCase(naturalSort())) + items = orderBy(items) return Promise.all(items.map(item => { const itemPath = path.join(dirPath, item) -- cgit 1.3.0-6-gf8a5