diff --git a/bin/clean.js b/bin/clean.js index e3d3f37c..d88f6e82 100755 --- a/bin/clean.js +++ b/bin/clean.js @@ -5,9 +5,9 @@ * Useful for developers. */ +var fs = require('fs') var os = require('os') var path = require('path') -var pathExists = require('path-exists') var rimraf = require('rimraf') var config = require('../config') @@ -15,7 +15,12 @@ var handlers = require('../main/handlers') rimraf.sync(config.CONFIG_PATH) -var tmpPath = path.join(pathExists.sync('/tmp') ? '/tmp' : os.tmpDir(), 'webtorrent') +var tmpPath +try { + tmpPath = path.join(fs.statSync('/tmp') && '/tmp', 'webtorrent') +} catch (err) { + tmpPath = path.join(os.tmpDir(), 'webtorrent') +} rimraf.sync(tmpPath) // Uninstall .torrent file and magnet link handlers diff --git a/config.js b/config.js index 8ec82a1d..55d501a3 100644 --- a/config.js +++ b/config.js @@ -1,6 +1,6 @@ var appConfig = require('application-config')('WebTorrent') +var fs = require('fs') var path = require('path') -var pathExists = require('path-exists') var APP_NAME = 'WebTorrent' var APP_TEAM = 'The WebTorrent Project' @@ -53,7 +53,11 @@ function getConfigPath () { } function isPortable () { - return process.platform === 'win32' && isProduction() && pathExists(PORTABLE_PATH) + try { + return process.platform === 'win32' && isProduction() && !!fs.statSync(PORTABLE_PATH) + } catch (err) { + return false + } } function isProduction () { diff --git a/package.json b/package.json index ea32621d..3bf0bfcb 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,6 @@ "main-loop": "^3.2.0", "musicmetadata": "^2.0.2", "network-address": "^1.1.0", - "path-exists": "^2.1.0", "prettier-bytes": "^1.0.1", "simple-get": "^2.0.0", "srt-to-vtt": "^1.1.1",