Skip to content

Commit 17c3f14

Browse files
authored
chore: replace make-dir with fs.mkdir (#10136)
1 parent ee40194 commit 17c3f14

File tree

8 files changed

+11
-16
lines changed

8 files changed

+11
-16
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
- `[jest-runtime]` Jest-internal sandbox escape hatch ([#9907](https://github.com/facebook/jest/pull/9907))
2323
- `[jest-fake-timers]` Update `now` param type to support `Date` in addition to `number`. ([#10169](https://github.com/facebook/jest/pull/10169))
2424
- `[docs]` Add param to `setSystemTime` docs and remove preceding period from it and `getRealSystemTime` ([#10169](https://github.com/facebook/jest/pull/10169))
25+
- `[jest-snapshot, jest-util]` Replace `make-dir` with `fs.mkdir` ([#10136](https://github.com/facebook/jest/pull/10136))
2526

2627
### Performance
2728

e2e/Utils.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import type {Config} from '@jest/types';
1111

1212
// eslint-disable-next-line import/named
1313
import {ExecaReturnValue, sync as spawnSync} from 'execa';
14-
import makeDir = require('make-dir');
1514
import rimraf = require('rimraf');
1615
import dedent = require('dedent');
1716
import which = require('which');
@@ -46,7 +45,7 @@ export const linkJestPackage = (packageName: string, cwd: Config.Path) => {
4645
const packagesDir = path.resolve(__dirname, '../packages');
4746
const packagePath = path.resolve(packagesDir, packageName);
4847
const destination = path.resolve(cwd, 'node_modules/', packageName);
49-
makeDir.sync(destination);
48+
fs.mkdirSync(destination, {recursive: true});
5049
rimraf.sync(destination);
5150
fs.symlinkSync(packagePath, destination, 'junction');
5251
};
@@ -77,12 +76,12 @@ export const writeFiles = (
7776
directory: string,
7877
files: {[filename: string]: string},
7978
) => {
80-
makeDir.sync(directory);
79+
fs.mkdirSync(directory, {recursive: true});
8180
Object.keys(files).forEach(fileOrPath => {
8281
const dirname = path.dirname(fileOrPath);
8382

8483
if (dirname !== '/') {
85-
makeDir.sync(path.join(directory, dirname));
84+
fs.mkdirSync(path.join(directory, dirname), {recursive: true});
8685
}
8786
fs.writeFileSync(
8887
path.resolve(directory, ...fileOrPath.split('/')),
@@ -95,13 +94,13 @@ export const writeSymlinks = (
9594
directory: string,
9695
symlinks: {[existingFile: string]: string},
9796
) => {
98-
makeDir.sync(directory);
97+
fs.mkdirSync(directory, {recursive: true});
9998
Object.keys(symlinks).forEach(fileOrPath => {
10099
const symLinkPath = symlinks[fileOrPath];
101100
const dirname = path.dirname(symLinkPath);
102101

103102
if (dirname !== '/') {
104-
makeDir.sync(path.join(directory, dirname));
103+
fs.mkdirSync(path.join(directory, dirname), {recursive: true});
105104
}
106105
fs.symlinkSync(
107106
path.resolve(directory, ...fileOrPath.split('/')),
@@ -165,7 +164,7 @@ export const createEmptyPackage = (
165164
},
166165
};
167166

168-
makeDir.sync(directory);
167+
fs.mkdirSync(directory, {recursive: true});
169168
packageJson || (packageJson = DEFAULT_PACKAGE_JSON);
170169
fs.writeFileSync(
171170
path.resolve(directory, 'package.json'),

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
"jest-watch-typeahead": "^0.5.0",
6060
"jquery": "^3.2.1",
6161
"lerna": "^3.20.2",
62-
"make-dir": "^3.0.0",
6362
"micromatch": "^4.0.2",
6463
"mock-fs": "^4.4.1",
6564
"opencollective": "^1.0.3",

packages/jest-snapshot/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
"jest-matcher-utils": "^26.0.1",
2323
"jest-message-util": "^26.0.1",
2424
"jest-resolve": "^26.0.1",
25-
"make-dir": "^3.0.0",
2625
"natural-compare": "^1.4.0",
2726
"pretty-format": "^26.0.1",
2827
"semver": "^7.3.2"

packages/jest-snapshot/src/utils.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import * as path from 'path';
99
import * as fs from 'graceful-fs';
10-
import makeDir = require('make-dir');
1110
import naturalCompare = require('natural-compare');
1211
import chalk = require('chalk');
1312
import type {Config} from '@jest/types';
@@ -183,7 +182,7 @@ const printBacktickString = (str: string): string =>
183182

184183
export const ensureDirectoryExists = (filePath: Config.Path): void => {
185184
try {
186-
makeDir.sync(path.join(path.dirname(filePath)));
185+
fs.mkdirSync(path.join(path.dirname(filePath)), {recursive: true});
187186
} catch (e) {}
188187
};
189188

packages/jest-util/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
"chalk": "^4.0.0",
1515
"graceful-fs": "^4.2.4",
1616
"is-ci": "^2.0.0",
17-
"make-dir": "^3.0.0",
1817
"micromatch": "^4.0.2"
1918
},
2019
"devDependencies": {

packages/jest-util/src/createDirectory.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import makeDir = require('make-dir');
8+
import * as fs from 'graceful-fs';
99
import type {Config} from '@jest/types';
1010

1111
export default function createDirectory(path: Config.Path): void {
1212
try {
13-
makeDir.sync(path);
13+
fs.mkdirSync(path, {recursive: true});
1414
} catch (e) {
1515
if (e.code !== 'EEXIST') {
1616
throw e;

scripts/build.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
const fs = require('fs');
2424
const path = require('path');
2525
const glob = require('glob');
26-
const makeDir = require('make-dir');
2726

2827
const babel = require('@babel/core');
2928
const chalk = require('chalk');
@@ -83,7 +82,7 @@ function buildFile(file, silent) {
8382
return;
8483
}
8584

86-
makeDir.sync(path.dirname(destPath));
85+
fs.mkdirSync(path.dirname(destPath), {recursive: true});
8786
if (
8887
!micromatch.isMatch(file, JS_FILES_PATTERN) &&
8988
!micromatch.isMatch(file, TS_FILES_PATTERN)

0 commit comments

Comments
 (0)