« get me outta code hell

Remove fs-extra - mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorrie <towerofnix@gmail.com>2018-06-29 19:55:24 -0300
committerFlorrie <towerofnix@gmail.com>2018-06-29 19:55:24 -0300
commit316c3e2509a73d824b7c3acfa302857b415c3221 (patch)
treeae3fd8597b099622cfe1f813ee32ce0cf68cecff
parente4bccdfdef777747a541693796fe598491498aed (diff)
Remove fs-extra
-rw-r--r--downloaders.js18
-rw-r--r--package-lock.json28
-rw-r--r--package.json1
3 files changed, 16 insertions, 31 deletions
diff --git a/downloaders.js b/downloaders.js
index b7582a9..f0833e7 100644
--- a/downloaders.js
+++ b/downloaders.js
@@ -4,7 +4,6 @@ const { spawn } = require('child_process')
 const { Base64 } = require('js-base64')
 const mkdirp = promisify(require('mkdirp'))
 const fs = require('fs')
-const fse = require('fs-extra')
 const fetch = require('node-fetch')
 const tempy = require('tempy')
 const path = require('path')
@@ -15,7 +14,22 @@ const rename = promisify(fs.rename)
 const stat = promisify(fs.stat)
 const readdir = promisify(fs.readdir)
 const symlink = promisify(fs.symlink)
-const copyFile = fse.copy
+
+const copyFile = (source, target) => {
+  // Stolen from https://stackoverflow.com/a/30405105/4633828
+  const rd = fs.createReadStream(source)
+  const wr = fs.createWriteStream(target)
+  return new Promise((resolve, reject) => {
+    rd.on('error', reject)
+    wr.on('error', reject)
+    wr.on('finish', resolve)
+    rd.pipe(wr)
+  }).catch(function(error) {
+    rd.destroy()
+    wr.end()
+    throw error
+  })
+}
 
 const cachify = (identifier, baseFunction) => {
   return async arg => {
diff --git a/package-lock.json b/package-lock.json
index 3bb41c1..9f98a0b 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -27,21 +27,6 @@
         "es6-error": "^3.0.1"
       }
     },
-    "fs-extra": {
-      "version": "6.0.1",
-      "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-6.0.1.tgz",
-      "integrity": "sha512-GnyIkKhhzXZUWFCaJzvyDLEEgDkPfb4/TPvJCJVuS8MWZgoSsErf++QpiAlDnKFcqhRlm+tIOcencCjyJE6ZCA==",
-      "requires": {
-        "graceful-fs": "^4.1.2",
-        "jsonfile": "^4.0.0",
-        "universalify": "^0.1.0"
-      }
-    },
-    "graceful-fs": {
-      "version": "4.1.11",
-      "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz",
-      "integrity": "sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg="
-    },
     "iac": {
       "version": "1.1.0",
       "resolved": "https://registry.npmjs.org/iac/-/iac-1.1.0.tgz",
@@ -52,14 +37,6 @@
       "resolved": "https://registry.npmjs.org/js-base64/-/js-base64-2.4.5.tgz",
       "integrity": "sha512-aUnNwqMOXw3yvErjMPSQu6qIIzUmT1e5KcU1OZxRDU1g/am6mzBvcrmLAYwzmB59BHPrh5/tKaiF4OPhqRWESQ=="
     },
-    "jsonfile": {
-      "version": "4.0.0",
-      "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz",
-      "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=",
-      "requires": {
-        "graceful-fs": "^4.1.6"
-      }
-    },
     "minimist": {
       "version": "0.0.8",
       "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
@@ -121,11 +98,6 @@
         "crypto-random-string": "^1.0.0"
       }
     },
-    "universalify": {
-      "version": "0.1.1",
-      "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.1.tgz",
-      "integrity": "sha1-+nG63UQ3r0wUiEHjs7Fl+enlkLc="
-    },
     "utf8-byte-length": {
       "version": "1.0.4",
       "resolved": "https://registry.npmjs.org/utf8-byte-length/-/utf8-byte-length-1.0.4.tgz",
diff --git a/package.json b/package.json
index af6ed3b..c16fc0c 100644
--- a/package.json
+++ b/package.json
@@ -11,7 +11,6 @@
   "dependencies": {
     "command-exists": "^1.2.6",
     "fifo-js": "^2.1.0",
-    "fs-extra": "^6.0.1",
     "iac": "^1.1.0",
     "js-base64": "^2.4.5",
     "mkdirp": "^0.5.1",