From 6b3d53a795fdd318aa6629d9f3e4f167eb450ae1 Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Sat, 19 Jan 2019 15:06:25 -0800 Subject: [PATCH] chore: remove pify dependency, use util.promisify (#901) --- bin/build-inline-script.js | 4 ++-- bin/build-sass.js | 8 ++++---- bin/build-svg.js | 4 ++-- bin/build-template-html.js | 4 ++-- bin/build-third-party-assets.js | 8 ++++---- bin/run-mastodon.js | 8 ++++---- package-lock.json | 5 ----- package.json | 1 - 8 files changed, 18 insertions(+), 24 deletions(-) diff --git a/bin/build-inline-script.js b/bin/build-inline-script.js index d67c951..ba8cbaf 100644 --- a/bin/build-inline-script.js +++ b/bin/build-inline-script.js @@ -1,6 +1,6 @@ import crypto from 'crypto' import fs from 'fs' -import pify from 'pify' +import { promisify } from 'util' import path from 'path' import { rollup } from 'rollup' import { terser } from 'rollup-plugin-terser' @@ -8,7 +8,7 @@ import replace from 'rollup-plugin-replace' import fromPairs from 'lodash-es/fromPairs' import { themes } from '../src/routes/_static/themes' -const writeFile = pify(fs.writeFile.bind(fs)) +const writeFile = promisify(fs.writeFile) const themeColors = fromPairs(themes.map(_ => ([_.name, _.color]))) diff --git a/bin/build-sass.js b/bin/build-sass.js index 36a3f51..061979f 100755 --- a/bin/build-sass.js +++ b/bin/build-sass.js @@ -1,11 +1,11 @@ import sass from 'node-sass' import path from 'path' import fs from 'fs' -import pify from 'pify' +import { promisify } from 'util' -const writeFile = pify(fs.writeFile.bind(fs)) -const readdir = pify(fs.readdir.bind(fs)) -const render = pify(sass.render.bind(sass)) +const writeFile = promisify(fs.writeFile) +const readdir = promisify(fs.readdir) +const render = promisify(sass.render.bind(sass)) const globalScss = path.join(__dirname, '../src/scss/global.scss') const defaultThemeScss = path.join(__dirname, '../src/scss/themes/_default.scss') diff --git a/bin/build-svg.js b/bin/build-svg.js index 0ad477c..1da2a9c 100755 --- a/bin/build-svg.js +++ b/bin/build-svg.js @@ -1,12 +1,12 @@ import svgs from './svgs' import path from 'path' import fs from 'fs' -import pify from 'pify' +import { promisify } from 'util' import SVGO from 'svgo' import $ from 'cheerio' const svgo = new SVGO() -const readFile = pify(fs.readFile.bind(fs)) +const readFile = promisify(fs.readFile) export async function buildSvg () { let result = (await Promise.all(svgs.map(async svg => { diff --git a/bin/build-template-html.js b/bin/build-template-html.js index 9bb4bf7..5a621cc 100644 --- a/bin/build-template-html.js +++ b/bin/build-template-html.js @@ -1,14 +1,14 @@ import chokidar from 'chokidar' import fs from 'fs' import path from 'path' -import pify from 'pify' +import { promisify } from 'util' import { buildSass } from './build-sass' import { buildInlineScript } from './build-inline-script' import { buildSvg } from './build-svg' import now from 'performance-now' import debounce from 'lodash-es/debounce' -const writeFile = pify(fs.writeFile.bind(fs)) +const writeFile = promisify(fs.writeFile) const DEBOUNCE = 500 diff --git a/bin/build-third-party-assets.js b/bin/build-third-party-assets.js index dbb5e6c..893a8b3 100644 --- a/bin/build-third-party-assets.js +++ b/bin/build-third-party-assets.js @@ -1,11 +1,11 @@ import path from 'path' import fs from 'fs' -import pify from 'pify' +import { promisify } from 'util' import CleanCSS from 'clean-css' -const writeFile = pify(fs.writeFile.bind(fs)) -const readFile = pify(fs.readFile.bind(fs)) -const copyFile = pify(fs.copyFile.bind(fs)) +const writeFile = promisify(fs.writeFile) +const readFile = promisify(fs.readFile) +const copyFile = promisify(fs.copyFile) async function compileThirdPartyCss () { let css = await readFile(path.resolve(__dirname, '../node_modules/emoji-mart/css/emoji-mart.css'), 'utf8') diff --git a/bin/run-mastodon.js b/bin/run-mastodon.js index 4137934..ca908c7 100644 --- a/bin/run-mastodon.js +++ b/bin/run-mastodon.js @@ -1,5 +1,5 @@ import { restoreMastodonData } from './restore-mastodon-data' -import pify from 'pify' +import { promisify } from 'util' import childProcessPromise from 'child-process-promise' import path from 'path' import fs from 'fs' @@ -8,9 +8,9 @@ import mkdirpCB from 'mkdirp' const exec = childProcessPromise.exec const spawn = childProcessPromise.spawn -const mkdirp = pify(mkdirpCB) -const stat = pify(fs.stat.bind(fs)) -const writeFile = pify(fs.writeFile.bind(fs)) +const mkdirp = promisify(mkdirpCB) +const stat = promisify(fs.stat) +const writeFile = promisify(fs.writeFile) const dir = __dirname const GIT_URL = 'https://github.com/tootsuite/mastodon.git' diff --git a/package-lock.json b/package-lock.json index 80bd083..bfb37ea 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7338,11 +7338,6 @@ "resolved": "https://registry.npmjs.org/pidtree/-/pidtree-0.3.0.tgz", "integrity": "sha512-9CT4NFlDcosssyg8KVFltgokyKZIFjoBxw8CTGy+5F38Y1eQWrt8tRayiUOXE+zVKQnYu5BR8JjCtvK3BcnBhg==" }, - "pify": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", - "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==" - }, "pinkie": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", diff --git a/package.json b/package.json index b506797..d702f1c 100644 --- a/package.json +++ b/package.json @@ -79,7 +79,6 @@ "p-any": "^1.1.0", "page-lifecycle": "^0.1.1", "performance-now": "^2.1.0", - "pify": "^4.0.1", "prop-types": "^15.6.2", "quick-lru": "^2.0.0", "remount": "^0.9.3",