From 35d24ba00a4885ac086c61412ea6e084a0fa0afa Mon Sep 17 00:00:00 2001 From: Florrie Date: Tue, 3 Jul 2018 01:15:28 -0300 Subject: Expand ~ in local crawl --- crawlers.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'crawlers.js') diff --git a/crawlers.js b/crawlers.js index 5a4987a..1db02fd 100644 --- a/crawlers.js +++ b/crawlers.js @@ -1,6 +1,7 @@ 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') @@ -238,8 +239,9 @@ function crawlLocal(dirPath, extensions = [ dirPath = decodeURIComponent(url.pathname) } } catch (error) { - // If it's not a URL, don't do anything special - it's (assumedly) an - // ordinary path ("/path/to/the directory"). + // If it's not a URL, it's (assumedly) an ordinary path ("/path/to/the directory"). + // In this case we'll expand any ~ in the path (e.g. ~/Music -> /home/.../Music). + dirPath = expandHomeDir(dirPath) } return readDir(dirPath).then(items => { -- cgit 1.3.0-6-gf8a5