Skip to content

Commit

Permalink
(refactor): replace rimraf, mkdirp, util.promisify with fs-extra funcs (
Browse files Browse the repository at this point in the history
#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
  • Loading branch information
agilgur5 authored Feb 26, 2020
1 parent 6a0a2c5 commit 3a6d42f
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 32 deletions.
4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down
5 changes: 2 additions & 3 deletions src/createEslintConfig.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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' }
Expand Down
7 changes: 4 additions & 3 deletions src/createProgressEstimator.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
22 changes: 0 additions & 22 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 3a6d42f

Please sign in to comment.