From 8cbae1fe17bbf51060734861540a398631635ad7 Mon Sep 17 00:00:00 2001 From: Florrie Date: Tue, 4 Feb 2020 22:57:28 -0400 Subject: more os.homedir() --- backend.js | 3 ++- downloaders.js | 4 ++-- guess.js | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/backend.js b/backend.js index 7ee6873..379a16b 100644 --- a/backend.js +++ b/backend.js @@ -7,6 +7,7 @@ const { getDownloaderFor } = require('./downloaders') const { getMetadataReaderFor } = require('./metadata-readers') const { getPlayer } = require('./players') const RecordStore = require('./record-store') +const os = require('os') const { getTimeStringsFromSec, @@ -568,7 +569,7 @@ class Backend extends EventEmitter { this.throttleMetadata = throttlePromise(10) this.metadataDictionary = {} - this.rootDirectory = process.env.HOME + '/.mtui' + this.rootDirectory = os.homedir() + '/.mtui' this.metadataPath = this.rootDirectory + '/track-metadata.json' } diff --git a/downloaders.js b/downloaders.js index 4c1ce38..e18c8e0 100644 --- a/downloaders.js +++ b/downloaders.js @@ -6,6 +6,7 @@ const mkdirp = promisify(require('mkdirp')) const fs = require('fs') const fetch = require('node-fetch') const tempy = require('tempy') +const os = require('os') const path = require('path') const sanitize = require('sanitize-filename') @@ -104,8 +105,7 @@ const removeFileProtocol = arg => { const downloaders = { extension: 'mp3', // Generally target file extension, used by youtube-dl - // TODO: Cross-platform stuff - rootCacheDir: process.env.HOME + '/.mtui/downloads', + rootCacheDir: os.homedir() + '/.mtui/downloads', http: cachify('http', arg => { diff --git a/guess.js b/guess.js index 56c614a..0748ce8 100644 --- a/guess.js +++ b/guess.js @@ -1,6 +1,7 @@ 'use strict' const Backend = require('./backend') +const os = require('os') const processSmartPlaylist = require('./smart-playlist') const { @@ -46,7 +47,7 @@ async function game() { } }) - const sourcePath = process.argv[2] || process.env.HOME + '/Music' + const sourcePath = process.argv[2] || os.homedir() + '/Music' let grouplike = {source: ['crawl-local', sourcePath]} grouplike = await processSmartPlaylist(grouplike) -- cgit 1.3.0-6-gf8a5