Skip to content

Commit

Permalink
chore: remove rimraf
Browse files Browse the repository at this point in the history
  • Loading branch information
jrandolf committed Mar 6, 2023
1 parent 8bf9718 commit 5cd6d57
Show file tree
Hide file tree
Showing 14 changed files with 230 additions and 111 deletions.
288 changes: 207 additions & 81 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"build:docs": "wireit",
"check:pinned-deps": "tsx tools/ensure-pinned-deps",
"check": "npm run check --workspaces --if-present && run-p check:*",
"clean": "rimraf **/.wireit && npm run clean --workspaces --if-present",
"clean": "rm -rf **/.wireit && npm run clean --workspaces --if-present",
"commitlint": "commitlint --from=HEAD~1",
"debug": "mocha --inspect-brk",
"docs": "run-s build:docs generate:markdown",
Expand Down Expand Up @@ -133,7 +133,6 @@
"@types/pngjs": "6.0.1",
"@types/progress": "2.0.5",
"@types/proxy-from-env": "1.0.1",
"@types/rimraf": "3.0.2",
"@types/semver": "7.3.13",
"@types/sinon": "10.0.13",
"@types/tar-fs": "2.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/browsers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"scripts": {
"build": "wireit",
"build:test": "wireit",
"clean": "tsc --build --clean && rimraf lib",
"clean": "tsc --build --clean && rm -rf lib",
"test": "wireit"
},
"bin": {
Expand Down
2 changes: 1 addition & 1 deletion packages/ng-schematics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"scripts": {
"build:tsc": "wireit",
"build": "wireit",
"clean": "tsc -b --clean && rimraf lib && rimraf test/build",
"clean": "tsc -b --clean && rm -rf lib && rm -rf test/build",
"dev:test": "npm run test --watch",
"dev": "npm run build --watch",
"test": "wireit"
Expand Down
5 changes: 2 additions & 3 deletions packages/puppeteer-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@
"url": "https://github.com/puppeteer/puppeteer/tree/main/packages/puppeteer-core"
},
"engines": {
"node": ">=14.1.0"
"node": ">=14.14.0"
},
"scripts": {
"build:docs": "wireit",
"build:tsc": "wireit",
"build:types": "wireit",
"build": "wireit",
"check": "tsx tools/ensure-correct-devtools-protocol-package",
"clean": "tsc -b --clean && rimraf lib src/generated",
"clean": "tsc -b --clean && rm -rf lib src/generated",
"generate:package-json": "wireit",
"generate:sources": "wireit",
"prepack": "wireit"
Expand Down Expand Up @@ -138,7 +138,6 @@
"extract-zip": "2.0.1",
"https-proxy-agent": "5.0.1",
"proxy-from-env": "1.1.0",
"rimraf": "3.0.2",
"tar-fs": "2.1.1",
"unbzip2-stream": "1.4.3",
"ws": "8.11.0"
Expand Down
9 changes: 3 additions & 6 deletions packages/puppeteer-core/src/node/BrowserFetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import {exec as execChildProcess} from 'child_process';
import {createReadStream, createWriteStream, existsSync, readdirSync} from 'fs';
import {chmod, mkdir, readdir, unlink} from 'fs/promises';
import {chmod, mkdir, readdir, rm, unlink} from 'fs/promises';
import * as http from 'http';
import * as https from 'https';
import * as os from 'os';
Expand All @@ -31,7 +31,6 @@ import createHttpsProxyAgent, {
HttpsProxyAgentOptions,
} from 'https-proxy-agent';
import {getProxyForUrl} from 'proxy-from-env';
import removeRecursive from 'rimraf';
import tar from 'tar-fs';
import bzip from 'unbzip2-stream';

Expand Down Expand Up @@ -404,7 +403,7 @@ export class BrowserFetcher {
* @remarks
* This method is affected by the current `product`.
* @param revision - A revision to remove for the current `product`.
* @returns A promise that resolves when the revision has been removes or
* @returns A promise that resolves when the revision has been removed or
* throws if the revision has not been downloaded.
*/
async remove(revision: string): Promise<void> {
Expand All @@ -413,9 +412,7 @@ export class BrowserFetcher {
existsSync(folderPath),
`Failed to remove: revision ${revision} is not downloaded`
);
await new Promise(fulfill => {
return removeRecursive(folderPath, fulfill);
});
await rm(folderPath, {recursive: true, force: true});
}

/**
Expand Down
8 changes: 3 additions & 5 deletions packages/puppeteer-core/src/node/BrowserRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@

import * as childProcess from 'child_process';
import * as fs from 'fs';
import {rm} from 'fs/promises';
import * as path from 'path';
import * as readline from 'readline';
import {promisify} from 'util';

import removeFolder from 'rimraf';

import type {Connection as BiDiConnection} from '../common/bidi/bidi.js';
import {Connection} from '../common/Connection.js';
import {debug} from '../common/Debug.js';
Expand All @@ -40,7 +39,6 @@ import {isErrnoException, isErrorLike} from '../util/ErrorLike.js';
import {LaunchOptions} from './LaunchOptions.js';
import {PipeTransport} from './PipeTransport.js';

const removeFolderAsync = promisify(removeFolder);
const renameAsync = promisify(fs.rename);
const unlinkAsync = promisify(fs.unlink);

Expand Down Expand Up @@ -126,7 +124,7 @@ export class BrowserRunner {
// Cleanup as processes exit.
if (this.#isTempUserDataDir) {
try {
await removeFolderAsync(this.#userDataDir);
await rm(this.#userDataDir, {recursive: true, force: true});
fulfill();
} catch (error) {
debugError(error);
Expand Down Expand Up @@ -240,7 +238,7 @@ export class BrowserRunner {
// Attempt to remove temporary profile directory to avoid littering.
try {
if (this.#isTempUserDataDir) {
removeFolder.sync(this.#userDataDir);
fs.rmSync(this.#userDataDir, {recursive: true, force: true});
}
} catch (error) {}

Expand Down
4 changes: 2 additions & 2 deletions packages/puppeteer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@
"url": "https://github.com/puppeteer/puppeteer/tree/main/packages/puppeteer"
},
"engines": {
"node": ">=14.1.0"
"node": ">=14.14.0"
},
"scripts": {
"build:docs": "wireit",
"build:tsc": "wireit",
"build:types": "wireit",
"build": "wireit",
"clean": "tsc -b --clean && rimraf lib",
"clean": "tsc -b --clean && rm -rf lib",
"generate:package-json": "wireit",
"postinstall": "node install.js",
"prepack": "wireit"
Expand Down
2 changes: 1 addition & 1 deletion packages/testserver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "lib/index.js",
"scripts": {
"build": "wireit",
"clean": "tsc -b --clean && rimraf lib"
"clean": "tsc -b --clean && rm -rf lib"
},
"wireit": {
"build": {
Expand Down
2 changes: 1 addition & 1 deletion test/installation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"build": "wireit",
"build:packages": "wireit",
"clean": "tsc -b --clean && rimraf build",
"clean": "tsc -b --clean && rm -rf build",
"test": "mocha"
},
"wireit": {
Expand Down
2 changes: 1 addition & 1 deletion test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"scripts": {
"build": "wireit",
"clean": "tsc -b --clean && rimraf build"
"clean": "tsc -b --clean && rm -rf build"
},
"wireit": {
"build": {
Expand Down
5 changes: 2 additions & 3 deletions test/src/headful.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

import fs from 'fs';
import {rm} from 'fs/promises';
import os from 'os';
import path from 'path';
import {promisify} from 'util';
Expand All @@ -24,11 +25,9 @@ import {
PuppeteerLaunchOptions,
PuppeteerNode,
} from 'puppeteer-core/internal/node/PuppeteerNode.js';
import rimraf from 'rimraf';

import {getTestState} from './mocha-utils.js';

const rmAsync = promisify(rimraf);
const mkdtempAsync = promisify(fs.mkdtemp);

const TMP_FOLDER = path.join(os.tmpdir(), 'pptr_tmp_folder-');
Expand Down Expand Up @@ -241,7 +240,7 @@ describe('headful tests', function () {
});
await headlessBrowser.close();
// This might throw. See https://github.com/puppeteer/puppeteer/issues/2778
await rmAsync(userDataDir).catch(() => {});
await rm(userDataDir, {recursive: true, force: true}).catch(() => {});
expect(cookie).toBe('foo=true');
});
// TODO: Support OOOPIF. @see https://github.com/puppeteer/puppeteer/issues/2548
Expand Down
6 changes: 4 additions & 2 deletions test/src/launcher.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/
import fs from 'fs';
import {rm} from 'fs/promises';
import os from 'os';
import path from 'path';
import {TLSSocket} from 'tls';
Expand All @@ -23,15 +24,16 @@ import {Protocol} from 'devtools-protocol';
import expect from 'expect';
import {BrowserFetcher, TimeoutError} from 'puppeteer';
import {Page} from 'puppeteer-core/internal/api/Page.js';
import rimraf from 'rimraf';
import sinon from 'sinon';

import {getTestState, itOnlyRegularInstall} from './mocha-utils.js';
import utils from './utils.js';

const rmAsync = (filename: string) => {
return rm(filename, {force: true, recursive: true});
};
const mkdtempAsync = promisify(fs.mkdtemp);
const readFileAsync = promisify(fs.readFile);
const rmAsync = promisify(rimraf);
const statAsync = promisify(fs.stat);
const writeFileAsync = promisify(fs.writeFile);

Expand Down
3 changes: 1 addition & 2 deletions test/src/mocha-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import {
} from 'puppeteer-core/internal/node/PuppeteerNode.js';
import {isErrorLike} from 'puppeteer-core/internal/util/ErrorLike.js';
import puppeteer from 'puppeteer/lib/cjs/puppeteer/puppeteer.js';
import rimraf from 'rimraf';
import sinon from 'sinon';

import {extendExpectWithToBeGolden} from './utils.js';
Expand Down Expand Up @@ -134,7 +133,7 @@ const setupGoldenAssertions = (): void => {
const GOLDEN_DIR = path.join(__dirname, `../golden-${suffix}`);
const OUTPUT_DIR = path.join(__dirname, `../output-${suffix}`);
if (fs.existsSync(OUTPUT_DIR)) {
rimraf.sync(OUTPUT_DIR);
fs.rmSync(OUTPUT_DIR, {recursive: true, force: true});
}
extendExpectWithToBeGolden(GOLDEN_DIR, OUTPUT_DIR);
};
Expand Down

0 comments on commit 5cd6d57

Please sign in to comment.