diff options
author | Liam <towerofnix@gmail.com> | 2017-05-31 14:17:53 -0300 |
---|---|---|
committer | Liam <towerofnix@gmail.com> | 2017-05-31 14:17:57 -0300 |
commit | f5879e2eb3c86057f6f4a9e477c28ba8edf3824d (patch) | |
tree | 0e305d57355d98e7e80aeea391e2ad6c9d6dff72 | |
parent | d1bf9f5e95f4306bd53b072bd62de98e6e5e3c58 (diff) |
Use util.promisify instead of mz/fs
One day I go from the deprecated fs-promise module to the mz/fs module, the next day Node.js v8.0.0 is released with the new util.promisify function.. Must I change to a new technology literally every day? :)
-rw-r--r-- | package.json | 1 | ||||
-rw-r--r-- | play.js | 15 | ||||
-rw-r--r-- | yarn.lock | 28 |
3 files changed, 10 insertions, 34 deletions
diff --git a/package.json b/package.json index 33069a4..4af34d5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,6 @@ { "dependencies": { "cheerio": "^1.0.0-rc.1", - "mz": "^2.6.0", "node-fetch": "^1.7.0", "sanitize-filename": "^1.6.1" } diff --git a/play.js b/play.js index badfcf4..8833c89 100644 --- a/play.js +++ b/play.js @@ -66,10 +66,15 @@ 'use strict' -const fs = require('mz/fs') +const fs = require('fs') +const util = require('util') +const { spawn } = require('child_process') + const fetch = require('node-fetch') const sanitize = require('sanitize-filename') -const { spawn } = require('child_process') + +const writeFile = util.promisify(fs.writeFile) +const readFile = util.promisify(fs.readFile) function promisifyProcess(proc, showLogging = true) { return new Promise((resolve, reject) => { @@ -152,7 +157,7 @@ async function loopPlay(fn) { const res = await fetch(href) const buffer = await res.buffer() - await fs.writeFile('./.temp-track', buffer) + await writeFile('./.temp-track', buffer) try { await convert('./.temp-track', wavFile) @@ -301,7 +306,7 @@ async function processArgv(argv, handlers) { } } -fs.readFile('./playlist.json', 'utf-8') +readFile('./playlist.json', 'utf-8') .then(plText => JSON.parse(plText)) .then(async playlist => { let sourcePlaylist = playlist @@ -321,7 +326,7 @@ fs.readFile('./playlist.json', 'utf-8') // Opens a separate playlist file. // This sets the source playlist. - const openedPlaylist = JSON.parse(await fs.readFile(util.nextArg(), 'utf-8')) + const openedPlaylist = JSON.parse(await readFile(util.nextArg(), 'utf-8')) sourcePlaylist = openedPlaylist curPlaylist = openedPlaylist }, diff --git a/yarn.lock b/yarn.lock index 5fb5fcb..4f46d69 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6,10 +6,6 @@ version "6.0.73" resolved "https://registry.yarnpkg.com/@types/node/-/node-6.0.73.tgz#85dc4bb6f125377c75ddd2519a1eeb63f0a4ed70" -any-promise@^1.0.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/any-promise/-/any-promise-1.3.0.tgz#abc6afeedcea52e809cdc0376aed3ce39635d17f" - boolbase@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/boolbase/-/boolbase-1.0.0.tgz#68dff5fbe60c51eb37725ea9e3ed310dcc1e776e" @@ -115,14 +111,6 @@ lodash@^4.15.0: version "4.17.4" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" -mz@^2.6.0: - version "2.6.0" - resolved "https://registry.yarnpkg.com/mz/-/mz-2.6.0.tgz#c8b8521d958df0a4f2768025db69c719ee4ef1ce" - dependencies: - any-promise "^1.0.0" - object-assign "^4.0.1" - thenify-all "^1.0.0" - node-fetch@^1.7.0: version "1.7.0" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.0.tgz#3ff6c56544f9b7fb00682338bb55ee6f54a8a0ef" @@ -136,10 +124,6 @@ nth-check@~1.0.1: dependencies: boolbase "~1.0.0" -object-assign@^4.0.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" - parse5@^3.0.1: version "3.0.2" resolved "https://registry.yarnpkg.com/parse5/-/parse5-3.0.2.tgz#05eff57f0ef4577fb144a79f8b9a967a6cc44510" @@ -178,18 +162,6 @@ string_decoder@~1.0.0: dependencies: safe-buffer "^5.0.1" -thenify-all@^1.0.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/thenify-all/-/thenify-all-1.6.0.tgz#1a1918d402d8fc3f98fbf234db0bcc8cc10e9726" - dependencies: - thenify ">= 3.1.0 < 4" - -"thenify@>= 3.1.0 < 4": - version "3.3.0" - resolved "https://registry.yarnpkg.com/thenify/-/thenify-3.3.0.tgz#e69e38a1babe969b0108207978b9f62b88604839" - dependencies: - any-promise "^1.0.0" - truncate-utf8-bytes@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/truncate-utf8-bytes/-/truncate-utf8-bytes-1.0.2.tgz#405923909592d56f78a5818434b0b78489ca5f2b" |