Skip to content

Commit

Permalink
Pivot to dropping mkdirp
Browse files Browse the repository at this point in the history
  • Loading branch information
ericanderson committed Feb 9, 2022
1 parent c09e216 commit 4036253
Show file tree
Hide file tree
Showing 14 changed files with 20 additions and 58 deletions.
25 changes: 0 additions & 25 deletions flow-typed/npm/mkdirp_v1.x.x.js

This file was deleted.

1 change: 0 additions & 1 deletion package.json
Expand Up @@ -32,7 +32,6 @@
"jest": "^26.6.3",
"lerna": "2.4.0",
"micromatch": "^4.0.2",
"mkdirp": "^1.0.4",
"prettier": "^2.4.1",
"progress": "^2.0.0",
"promise": "^8.0.3",
Expand Down
3 changes: 1 addition & 2 deletions packages/buck-worker-tool/package.json
Expand Up @@ -12,8 +12,7 @@
"temp": "^0.8.3"
},
"devDependencies": {
"metro-memory-fs": "0.67.0",
"mkdirp": "^1.0.4"
"metro-memory-fs": "0.67.0"
},
"scripts": {
"prepare-release": "test -d build && rm -rf src.real && mv src src.real && mv build src",
Expand Down
3 changes: 1 addition & 2 deletions packages/buck-worker-tool/src/__tests__/worker-test.js
Expand Up @@ -35,7 +35,6 @@ const buckWorker = require('../worker-tool');
// mocked
const {Console} = require('console');
const fs = require('fs');
const mkdirp = require('mkdirp');
const path = require('path');

const {any, anything} = expect;
Expand Down Expand Up @@ -123,7 +122,7 @@ describe('Buck worker:', () => {
fs.writeFileSync(path.join(dirPath, key), entry || '');
} else {
const subDirPath = path.join(dirPath, key);
mkdirp.sync(subDirPath);
fs.mkdirSync(subDirPath, {recursive: true});
writeFiles(entry, subDirPath);
}
}
Expand Down
1 change: 0 additions & 1 deletion packages/metro-cache/package.json
Expand Up @@ -13,7 +13,6 @@
},
"dependencies": {
"metro-core": "0.67.0",
"mkdirp": "^1.0.4",
"rimraf": "^2.5.4"
},
"devDependencies": {
Expand Down
7 changes: 4 additions & 3 deletions packages/metro-cache/src/stores/FileStore.js
Expand Up @@ -11,7 +11,6 @@
'use strict';

const fs = require('fs');
const mkdirp = require('mkdirp');
const path = require('path');
const rimraf = require('rimraf');

Expand Down Expand Up @@ -54,7 +53,7 @@ class FileStore<T> {
await this._set(filePath, value);
} catch (err) {
if (err.code === 'ENOENT') {
mkdirp.sync(path.dirname(filePath));
fs.mkdirSync(path.dirname(filePath), {recursive: true});
await this._set(filePath, value);
} else {
throw err;
Expand Down Expand Up @@ -87,7 +86,9 @@ class FileStore<T> {

_createDirs() {
for (let i = 0; i < 256; i++) {
mkdirp.sync(path.join(this._root, ('0' + i.toString(16)).slice(-2)));
fs.mkdirSync(path.join(this._root, ('0' + i.toString(16)).slice(-2)), {
recursive: true,
});
}
}

Expand Down
3 changes: 1 addition & 2 deletions packages/metro-transform-worker/package.json
Expand Up @@ -30,7 +30,6 @@
"devDependencies": {
"metro-memory-fs": "0.67.0",
"metro-minify-uglify": "0.67.0",
"metro-react-native-babel-transformer": "0.67.0",
"mkdirp": "^1.0.4"
"metro-react-native-babel-transformer": "0.67.0"
}
}
6 changes: 2 additions & 4 deletions packages/metro-transform-worker/src/__tests__/index-test.js
Expand Up @@ -39,7 +39,6 @@ const HEADER_DEV =
const HEADER_PROD = '__d(function (g, r, i, a, m, e, d) {';

let fs;
let mkdirp;
let Transformer;

const baseConfig: JsTransformerConfig = {
Expand Down Expand Up @@ -72,12 +71,11 @@ beforeEach(() => {
jest.mock('fs', () => new (require('metro-memory-fs'))());

fs = require('fs');
mkdirp = require('mkdirp');
Transformer = require('../');
fs.reset();

mkdirp.sync('/root/local');
mkdirp.sync(path.dirname(babelTransformerPath));
fs.mkdirSync('/root/local', {recursive: true});
fs.mkdirSync(path.dirname(babelTransformerPath), {recursive: true});
fs.writeFileSync(babelTransformerPath, transformerContents);
});

Expand Down
1 change: 0 additions & 1 deletion packages/metro/package.json
Expand Up @@ -53,7 +53,6 @@
"metro-transform-plugins": "0.67.0",
"metro-transform-worker": "0.67.0",
"mime-types": "^2.1.27",
"mkdirp": "^1.0.4",
"node-fetch": "^2.2.0",
"nullthrows": "^1.1.1",
"rimraf": "^2.5.4",
Expand Down
5 changes: 2 additions & 3 deletions packages/metro/src/DeltaBundler/__tests__/Transformer-test.js
Expand Up @@ -22,7 +22,6 @@ var Transformer = require('../Transformer');
var fs = require('fs');
var {getDefaultValues} = require('metro-config/src/defaults');
var {mergeConfig} = require('metro-config/src/loadConfig');
const mkdirp = require('mkdirp');

describe('Transformer', function () {
let watchFolders;
Expand Down Expand Up @@ -53,8 +52,8 @@ describe('Transformer', function () {
projectRoot = '/root';
watchFolders = [projectRoot];

mkdirp.sync('/path/to');
mkdirp.sync('/root');
fs.mkdirSync('/path/to', {recursive: true});
fs.mkdirSync('/root', {recursive: true});
fs.writeFileSync('/path/to/transformer.js', '');

require('../getTransformCacheKey').mockClear();
Expand Down
9 changes: 4 additions & 5 deletions packages/metro/src/__tests__/Assets-test.js
Expand Up @@ -16,7 +16,6 @@ jest.mock('image-size');
const {getAsset, getAssetData} = require('../Assets');
const crypto = require('crypto');
const fs = require('fs');
const mkdirp = require('mkdirp');
const path = require('path');

const mockImageWidth = 300;
Expand All @@ -30,7 +29,7 @@ require('image-size').mockReturnValue({
describe('getAsset', () => {
beforeEach(() => {
fs.reset();
mkdirp.sync('/root/imgs');
fs.mkdirSync('/root/imgs', {recursive: true});
});

it('should fail if the extension is not registerd', async () => {
Expand Down Expand Up @@ -121,7 +120,7 @@ describe('getAsset', () => {
});

it('should find an image located on a watchFolder', async () => {
mkdirp.sync('/anotherfolder');
fs.mkdirSync('/anotherfolder', {recursive: true});

writeImages({
'../../anotherfolder/b.png': 'b image',
Expand All @@ -139,7 +138,7 @@ describe('getAsset', () => {
});

it('should throw an error if an image is not located on any watchFolder', async () => {
mkdirp.sync('/anotherfolder');
fs.mkdirSync('/anotherfolder', {recursive: true});

writeImages({
'../../anotherfolder/b.png': 'b image',
Expand All @@ -154,7 +153,7 @@ describe('getAsset', () => {
describe('getAssetData', () => {
beforeEach(() => {
fs.reset();
mkdirp.sync('/root/imgs');
fs.mkdirSync('/root/imgs', {recursive: true});
});

it('should get assetData', () => {
Expand Down
6 changes: 4 additions & 2 deletions packages/metro/src/shared/output/RamBundle/as-assets.js
Expand Up @@ -19,8 +19,9 @@ const writeFile = require('../writeFile');
const buildSourcemapWithMetadata = require('./buildSourcemapWithMetadata');
const MAGIC_RAM_BUNDLE_NUMBER = require('./magic-number');
const {joinModules} = require('./util');
const fs = require('fs');
const util = require('util');
const writeSourceMap = require('./write-sourcemap');
const mkdirp = require('mkdirp');
const path = require('path');
// must not start with a dot, as that won't go into the apk
const MAGIC_RAM_BUNDLE_FILENAME = 'UNBUNDLE';
Expand Down Expand Up @@ -86,7 +87,8 @@ function saveAsAssets(
}

function createDir(dirName: string): Promise<empty> {
return mkdirp(dirName).then(() => undefined);
const mkdirPromised = util.promisify(fs.mkdir);
return mkdirPromised(dirName, {recursive: true}).then(() => undefined);
}

function writeModuleFile(
Expand Down
3 changes: 1 addition & 2 deletions scripts/build.js
Expand Up @@ -29,7 +29,6 @@ const chalk = require('chalk');
const fs = require('fs');
const glob = require('glob');
const micromatch = require('micromatch');
const mkdirp = require('mkdirp');
const path = require('path');
const prettier = require('prettier');

Expand Down Expand Up @@ -80,7 +79,7 @@ function buildPackage(p) {
function buildFile(file, silent) {
const destPath = getBuildPath(file, BUILD_DIR);

mkdirp.sync(path.dirname(destPath));
fs.mkdirSync(path.dirname(destPath), {recursive: true});
if (micromatch.isMatch(file, IGNORE_PATTERN)) {
silent ||
process.stdout.write(
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Expand Up @@ -5596,11 +5596,6 @@ mixin-deep@^1.2.0:
for-in "^1.0.2"
is-extendable "^1.0.1"

mkdirp@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e"
integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==

mkdirp@~0.5.0:
version "0.5.3"
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.3.tgz#5a514b7179259287952881e94410ec5465659f8c"
Expand Down

0 comments on commit 4036253

Please sign in to comment.