Skip to content

Commit 14b6ec4

Browse files
brendankennypaulirish
authored andcommitted
deps: remove mkdirp and make-dir for fs.mkdir (GoogleChrome#9858)
1 parent 848b543 commit 14b6ec4

File tree

10 files changed

+13
-40
lines changed

10 files changed

+13
-40
lines changed

build/build-bundle.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212

1313
const fs = require('fs');
1414
const path = require('path');
15+
const mkdir = fs.promises.mkdir;
1516

1617
const LighthouseRunner = require('../lighthouse-core/runner.js');
1718
const babel = require('babel-core');
1819
const browserify = require('browserify');
19-
const makeDir = require('make-dir');
2020
const pkg = require('../package.json');
2121

2222
const VERSION = pkg.version;
@@ -66,7 +66,6 @@ async function browserifyFile(entryPath, distPath) {
6666
.ignore('intl')
6767
.ignore('intl-pluralrules')
6868
.ignore('raven')
69-
.ignore('mkdirp')
7069
.ignore('rimraf')
7170
.ignore('pako/lib/zlib/inflate.js');
7271

@@ -104,7 +103,7 @@ async function browserifyFile(entryPath, distPath) {
104103
const bundleStream = bundle.bundle();
105104

106105
// Make sure path exists.
107-
await makeDir(path.dirname(distPath));
106+
await mkdir(path.dirname(distPath), {recursive: true});
108107
return new Promise((resolve, reject) => {
109108
const writeStream = fs.createWriteStream(distPath);
110109
writeStream.on('finish', resolve);

build/build-extension.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
'use strict';
77

88
const fs = require('fs');
9+
const mkdir = fs.promises.mkdir;
910

1011
const archiver = require('archiver');
1112
const cpy = require('cpy');
12-
const makeDir = require('make-dir');
1313
const bundleBuilder = require('./build-bundle.js');
1414

1515
const sourceName = 'extension-entry.js';
@@ -38,7 +38,7 @@ async function copyPopup() {
3838
popupSrc = popupSrc.replace(/__COMMITHASH__/g, bundleBuilder.COMMIT_HASH);
3939

4040
const popupDir = `${distDir}/scripts`;
41-
await makeDir(popupDir);
41+
await mkdir(popupDir, {recursive: true});
4242
fs.writeFileSync(`${popupDir}/popup.js`, popupSrc);
4343
}
4444

@@ -65,7 +65,7 @@ async function copyAssets() {
6565
*/
6666
async function packageExtension() {
6767
const packagePath = `${distDir}/../extension-package`;
68-
await makeDir(packagePath);
68+
await mkdir(packagePath, {recursive: true});
6969

7070
return new Promise((resolve, reject) => {
7171
const archive = archiver('zip', {

build/build-lightrider-bundles.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
const browserify = require('browserify');
99
const fs = require('fs');
1010
const path = require('path');
11-
const makeDir = require('make-dir');
1211
const bundleBuilder = require('./build-bundle.js');
1312
const {minifyFileTransform} = require('./build-utils.js');
1413

@@ -21,7 +20,7 @@ const generatorFilename = `./lighthouse-core/report/report-generator.js`;
2120
const entrySourceName = 'lightrider-entry.js';
2221
const entryDistName = 'lighthouse-lr-bundle.js';
2322

24-
makeDir.sync(path.dirname(distDir));
23+
fs.mkdirSync(path.dirname(distDir), {recursive: true});
2524

2625
/**
2726
* Browserify and minify entry point.

build/build-viewer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ const path = require('path');
1010
const {promisify} = require('util');
1111
const readFileAsync = promisify(fs.readFile);
1212
const writeFileAsync = promisify(fs.writeFile);
13+
const mkdir = fs.promises.mkdir;
1314

1415
const browserify = require('browserify');
1516
const cpy = require('cpy');
1617
const ghPages = require('gh-pages');
1718
const glob = promisify(require('glob'));
1819
const lighthousePackage = require('../package.json');
19-
const makeDir = require('make-dir');
2020
const rimraf = require('rimraf');
2121
const terser = require('terser');
2222
const {minifyFileTransform} = require('./build-utils.js');
@@ -59,7 +59,7 @@ async function loadFiles(pattern) {
5959
*/
6060
async function safeWriteFileAsync(filePath, data) {
6161
const fileDir = path.dirname(filePath);
62-
await makeDir(fileDir);
62+
await mkdir(fileDir, {recursive: true});
6363
return writeFileAsync(filePath, data);
6464
}
6565

build/tests/bundled-lighthouse-cli.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
const fs = require('fs');
2525
const path = require('path');
26-
const mkdirp = require('mkdirp');
2726
const rimraf = require('rimraf');
2827
const ChromeProtocol = require('../../lighthouse-core/gather/connections/cri.js');
2928

@@ -51,16 +50,13 @@ const lighthouse = (function getLighthouseCoreBundled() {
5150
// TODO: use `globalThis` when we drop Node 10.
5251
.replace('new ChromeProtocol', 'new global.ChromeProtocol')
5352
// Needed for asset-saver.js.
54-
.replace(/mkdirp\./g, 'global.mkdirp.')
5553
.replace(/rimraf\./g, 'global.rimraf.')
56-
.replace(/fs\.(writeFileSync|createWriteStream)/g, 'global.$&');
54+
.replace(/fs\.(writeFileSync|createWriteStream|mkdirSync)/g, 'global.$&');
5755

5856
/* eslint-disable no-undef */
5957
// @ts-ignore
6058
global.ChromeProtocol = ChromeProtocol;
6159
// @ts-ignore
62-
global.mkdirp = mkdirp;
63-
// @ts-ignore
6460
global.rimraf = rimraf;
6561
// @ts-ignore
6662
global.fs = fs;

lighthouse-cli/test/smokehouse/smokehouse.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
/* eslint-disable no-console */
1010

1111
const fs = require('fs');
12-
const mkdirp = require('mkdirp');
1312
const spawnSync = require('child_process').spawnSync;
1413
const yargs = require('yargs');
1514
const log = require('lighthouse-logger');
@@ -127,7 +126,7 @@ if (!smokeTest) {
127126

128127
const lhRootDir = `${__dirname}/../../..`;
129128
const tmpDir = `${lhRootDir}/.tmp`;
130-
mkdirp.sync(tmpDir);
129+
fs.mkdirSync(tmpDir, {recursive: true});
131130
const configPath = `${tmpDir}/smoke-config-${smokeTest.id}.json`;
132131
fs.writeFileSync(configPath, JSON.stringify(smokeTest.config));
133132

lighthouse-core/lib/asset-saver.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ const Simulator = require('./dependency-graph/simulator/simulator.js');
1313
const lanternTraceSaver = require('./lantern-trace-saver.js');
1414
const Metrics = require('./traces/pwmetrics-events.js');
1515
const rimraf = require('rimraf');
16-
const mkdirp = require('mkdirp');
1716
const NetworkAnalysisComputed = require('../computed/network-analysis.js');
1817
const LoadSimulatorComputed = require('../computed/load-simulator.js');
1918
const LHError = require('../lib/lh-error.js');
@@ -100,7 +99,7 @@ function stringifyReplacer(key, value) {
10099
async function saveArtifacts(artifacts, basePath) {
101100
const status = {msg: 'Saving artifacts', id: 'lh:assetSaver:saveArtifacts'};
102101
log.time(status);
103-
mkdirp.sync(basePath);
102+
fs.mkdirSync(basePath, {recursive: true});
104103
rimraf.sync(`${basePath}/*${traceSuffix}`);
105104
rimraf.sync(`${basePath}/${artifactsFilename}`);
106105

lighthouse-core/scripts/build-report-for-autodeployment.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
/* eslint-disable no-console */
1111
const fs = require('fs');
1212
const path = require('path');
13-
const mkdirp = require('mkdirp').sync;
1413
const rimraf = require('rimraf').sync;
1514
const swapLocale = require('../lib/i18n/swap-locale.js');
1615

@@ -45,7 +44,7 @@ const DIST = path.join(__dirname, `../../dist/now`);
4544
html = html.replace(`"lh-root lh-vars"`, `"lh-root lh-vars lh-devtools"`);
4645
}
4746
const filepath = `${DIST}/${variant}${filename}/index.html`;
48-
mkdirp(path.dirname(filepath));
47+
fs.mkdirSync(path.dirname(filepath), {recursive: true});
4948
fs.writeFileSync(filepath, html, {encoding: 'utf-8'});
5049
console.log('✅', filepath, 'written.');
5150
}
@@ -96,7 +95,7 @@ async function generateErrorLHR() {
9695

9796
// Save artifacts to disk then run `lighthouse -G` with them.
9897
const TMP = `${DIST}/.tmp/`;
99-
mkdirp(TMP);
98+
fs.mkdirSync(TMP, {recursive: true});
10099
fs.writeFileSync(`${TMP}/artifacts.json`, JSON.stringify(artifacts), 'utf-8');
101100
const errorRunnerResult = await lighthouse(artifacts.URL.requestedUrl, {auditMode: TMP});
102101

package.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,6 @@
8585
"@types/jpeg-js": "^0.3.0",
8686
"@types/lodash.isequal": "^4.5.2",
8787
"@types/lodash.set": "^4.3.6",
88-
"@types/make-dir": "^1.0.3",
89-
"@types/mkdirp": "^0.5.2",
9088
"@types/node": "*",
9189
"@types/raven": "^2.5.1",
9290
"@types/resize-observer-browser": "^0.1.1",
@@ -121,7 +119,6 @@
121119
"isomorphic-fetch": "^2.2.1",
122120
"jest": "^24.3.0",
123121
"jsdom": "^12.2.0",
124-
"make-dir": "^1.3.0",
125122
"npm-run-posix-or-windows": "^2.0.2",
126123
"nyc": "^13.3.0",
127124
"package-json-versionify": "^1.0.4",
@@ -151,7 +148,6 @@
151148
"lodash.set": "^4.3.2",
152149
"lookup-closest-locale": "6.0.4",
153150
"metaviewport-parser": "0.2.0",
154-
"mkdirp": "0.5.1",
155151
"open": "^6.4.0",
156152
"parse-cache-control": "1.0.1",
157153
"raven": "^2.2.1",

yarn.lock

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -541,25 +541,11 @@
541541
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.106.tgz#6093e9a02aa567ddecfe9afadca89e53e5dce4dd"
542542
integrity sha512-tOSvCVrvSqFZ4A/qrqqm6p37GZoawsZtoR0SJhlF7EonNZUgrn8FfT+RNQ11h+NUpMt6QVe36033f3qEKBwfWA==
543543

544-
"@types/make-dir@^1.0.3":
545-
version "1.0.3"
546-
resolved "https://registry.yarnpkg.com/@types/make-dir/-/make-dir-1.0.3.tgz#91fb52cefd07b0755d2373bcd46229765197ca3e"
547-
integrity sha512-bFRvlvUdPwxj47K2yVh7OBL8Mu8h//5k/hQJkz0iAZAlxhnIDydFezGA96zehtnRfrZDuIyPd+RC2kmBGtcs0w==
548-
dependencies:
549-
"@types/node" "*"
550-
551544
"@types/minimatch@*":
552545
version "3.0.3"
553546
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d"
554547
integrity sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==
555548

556-
"@types/mkdirp@^0.5.2":
557-
version "0.5.2"
558-
resolved "https://registry.yarnpkg.com/@types/mkdirp/-/mkdirp-0.5.2.tgz#503aacfe5cc2703d5484326b1b27efa67a339c1f"
559-
integrity sha512-U5icWpv7YnZYGsN4/cmh3WD2onMY0aJIiTE6+51TwJCttdHvtCYmkBNOobHlXwrJRL0nkH9jH4kD+1FAdMN4Tg==
560-
dependencies:
561-
"@types/node" "*"
562-
563549
"@types/node@*":
564550
version "10.14.0"
565551
resolved "https://registry.yarnpkg.com/@types/node/-/node-10.14.0.tgz#1c297530428c6f4e0a0a3222f5b44745669aa9f7"

0 commit comments

Comments
 (0)