From 3a6d42fb767150233c651056aabda9dd91bd048d Mon Sep 17 00:00:00 2001 From: Anton Gilgur Date: Wed, 26 Feb 2020 09:04:57 -0500 Subject: [PATCH] (refactor): replace rimraf, mkdirp, util.promisify with fs-extra funcs (#501) - they're a lot cleaner and this is one of the explicit goals of fs-extra per its "Why?" section of its README - it's also already used internally in most places, so this nixes the remaining places (deps): remove rimraf, mkdirp, and their @types/ packages --- package.json | 4 ---- src/createEslintConfig.ts | 5 ++--- src/createProgressEstimator.ts | 7 ++++--- yarn.lock | 22 ---------------------- 4 files changed, 6 insertions(+), 32 deletions(-) diff --git a/package.json b/package.json index 55a84fe79..97bad20a7 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,6 @@ "@rollup/plugin-json": "^4.0.0", "@rollup/plugin-node-resolve": "^7.1.0", "@rollup/plugin-replace": "^2.2.1", - "@types/rimraf": "^2.0.2", "@types/shelljs": "^0.8.5", "@typescript-eslint/eslint-plugin": "^2.12.0", "@typescript-eslint/parser": "^2.12.0", @@ -83,12 +82,10 @@ "jest-watch-typeahead": "^0.4.0", "jpjs": "^1.2.1", "lodash.merge": "^4.6.2", - "mkdirp": "^0.5.1", "ora": "^3.4.0", "pascal-case": "^2.0.1", "prettier": "^1.19.1", "progress-estimator": "^0.2.2", - "rimraf": "^3.0.0", "rollup": "^1.27.8", "rollup-plugin-babel": "^4.3.2", "rollup-plugin-sourcemaps": "^0.4.2", @@ -108,7 +105,6 @@ "@types/execa": "^0.9.0", "@types/fs-extra": "^8.0.0", "@types/jest": "^24.0.15", - "@types/mkdirp": "^0.5.2", "@types/ms": "^0.7.30", "@types/node": "^13.1.0", "@types/ora": "^3.2.0", diff --git a/src/createEslintConfig.ts b/src/createEslintConfig.ts index 26b356eb0..14fbb0382 100644 --- a/src/createEslintConfig.ts +++ b/src/createEslintConfig.ts @@ -1,6 +1,5 @@ -import fs from 'fs'; +import fs from 'fs-extra'; import path from 'path'; -import util from 'util'; import { CLIEngine } from 'eslint'; import { PackageJson } from './types'; import { getReactVersion } from './utils'; @@ -37,7 +36,7 @@ export async function createEslintConfig({ const file = path.join(rootDir, '.eslintrc.js'); try { - await util.promisify(fs.writeFile)( + await fs.writeFile( file, `module.exports = ${JSON.stringify(config, null, 2)}`, { flag: 'wx' } diff --git a/src/createProgressEstimator.ts b/src/createProgressEstimator.ts index 8962945eb..e3eba5ce3 100644 --- a/src/createProgressEstimator.ts +++ b/src/createProgressEstimator.ts @@ -1,10 +1,11 @@ +import fs from 'fs-extra'; + import { paths } from './constants'; -import util from 'util'; -import mkdirp from 'mkdirp'; + const progressEstimator = require('progress-estimator'); export async function createProgressEstimator() { - await util.promisify(mkdirp)(paths.progressEstimatorCache); + await fs.ensureDir(paths.progressEstimatorCache); return progressEstimator({ // All configuration keys are optional, but it's recommended to specify a storage location. storagePath: paths.progressEstimatorCache, diff --git a/yarn.lock b/yarn.lock index c995e22cd..047eae39b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1098,13 +1098,6 @@ resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d" integrity sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA== -"@types/mkdirp@^0.5.2": - version "0.5.2" - resolved "https://registry.yarnpkg.com/@types/mkdirp/-/mkdirp-0.5.2.tgz#503aacfe5cc2703d5484326b1b27efa67a339c1f" - integrity sha512-U5icWpv7YnZYGsN4/cmh3WD2onMY0aJIiTE6+51TwJCttdHvtCYmkBNOobHlXwrJRL0nkH9jH4kD+1FAdMN4Tg== - dependencies: - "@types/node" "*" - "@types/mri@*": version "1.1.0" resolved "https://registry.yarnpkg.com/@types/mri/-/mri-1.1.0.tgz#66555e4d797713789ea0fefdae0898d8170bf5af" @@ -1162,14 +1155,6 @@ dependencies: "@types/node" "*" -"@types/rimraf@^2.0.2": - version "2.0.3" - resolved "https://registry.yarnpkg.com/@types/rimraf/-/rimraf-2.0.3.tgz#0199a46af106729ba14213fda7b981278d8c84f2" - integrity sha512-dZfyfL/u9l/oi984hEXdmAjX3JHry7TLWw43u1HQ8HhPv6KtfxnrZ3T/bleJ0GEvnk9t5sM7eePkgMqz3yBcGg== - dependencies: - "@types/glob" "*" - "@types/node" "*" - "@types/rollup-plugin-json@^3.0.2": version "3.0.2" resolved "https://registry.yarnpkg.com/@types/rollup-plugin-json/-/rollup-plugin-json-3.0.2.tgz#1153136a515ed4fbb7ef214ace496f5fc3ed7796" @@ -5618,13 +5603,6 @@ rimraf@^2.5.4, rimraf@^2.6.1, rimraf@^2.6.3: dependencies: glob "^7.1.3" -rimraf@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.0.tgz#614176d4b3010b75e5c390eb0ee96f6dc0cebb9b" - integrity sha512-NDGVxTsjqfunkds7CqsOiEnxln4Bo7Nddl3XhS4pXg5OzwkLqJ971ZVAAnB+DDLnF76N+VnDEiBHaVV8I06SUg== - dependencies: - glob "^7.1.3" - rollup-plugin-babel@^4.3.2: version "4.3.3" resolved "https://registry.yarnpkg.com/rollup-plugin-babel/-/rollup-plugin-babel-4.3.3.tgz#7eb5ac16d9b5831c3fd5d97e8df77ba25c72a2aa"