Skip to content

Commit

Permalink
chore: remove path-exists
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesHenry committed Mar 24, 2023
1 parent e453420 commit 904ff29
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ jobs:
# Ignored specs currently failing on windows
# TODO: investigate why
npx nx run-many -t test --parallel=3 --ci --maxWorkers=2 --testTimeout=45000 --testPathIgnorePatterns=create-symlink.spec.ts --testPathIgnorePatterns=get-two-factor-auth-required.spec.ts --testPathIgnorePatterns=version-lifecycle-scripts.spec.ts --testPathIgnorePatterns=version-allow-branch.spec.ts --testPathIgnorePatterns=version-message.spec.ts --testPathIgnorePatterns=version-conventional-commits.spec.ts --testPathIgnorePatterns=version-bump-prerelease.spec.ts --testPathIgnorePatterns=version-bump.spec.ts --testPathIgnorePatterns=version-git-hosted-siblings.spec.ts --testPathIgnorePatterns=version-command.spec.ts --testPathIgnorePatterns=bootstrap-command.spec.ts --testPathIgnorePatterns=import-command.spec.ts --testPathIgnorePatterns=publish-command.spec.ts --testPathIgnorePatterns=publish-licenses.spec.ts --testPathIgnorePatterns=publish-lifecycle-scripts.spec.ts --testPathIgnorePatterns=publish-tagging.spec.ts --testPathIgnorePatterns=publish-relative-file-specifiers.spec.ts &
npx nx run-many -t test --parallel=3 --ci --maxWorkers=2 --testTimeout=60000 --testPathIgnorePatterns=create-symlink.spec.ts --testPathIgnorePatterns=get-two-factor-auth-required.spec.ts --testPathIgnorePatterns=version-lifecycle-scripts.spec.ts --testPathIgnorePatterns=version-allow-branch.spec.ts --testPathIgnorePatterns=version-message.spec.ts --testPathIgnorePatterns=version-conventional-commits.spec.ts --testPathIgnorePatterns=version-bump-prerelease.spec.ts --testPathIgnorePatterns=version-bump.spec.ts --testPathIgnorePatterns=version-git-hosted-siblings.spec.ts --testPathIgnorePatterns=version-command.spec.ts --testPathIgnorePatterns=bootstrap-command.spec.ts --testPathIgnorePatterns=import-command.spec.ts --testPathIgnorePatterns=publish-command.spec.ts --testPathIgnorePatterns=publish-licenses.spec.ts --testPathIgnorePatterns=publish-lifecycle-scripts.spec.ts --testPathIgnorePatterns=publish-tagging.spec.ts --testPathIgnorePatterns=publish-relative-file-specifiers.spec.ts &
pids+=($!)
Expand Down
25 changes: 12 additions & 13 deletions libs/commands/import/src/lib/import-command.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
import execa from "execa";
import fs from "fs-extra";
import path from "path";
import pathExists from "path-exists";

const promptConfirmation = jest.mocked(_promptConfirmation);

Expand Down Expand Up @@ -45,7 +44,7 @@ describe("ImportCommand", () => {
await lernaImport(testDir)(externalDir);

expect(await lastCommitInDir(testDir)).toBe("Init external commit");
expect(await pathExists(packageJson)).toBe(true);
expect(fs.existsSync(packageJson)).toBe(true);
});

it("imports a repo with conflicted merge commits when run with --flatten", async () => {
Expand Down Expand Up @@ -84,7 +83,7 @@ describe("ImportCommand", () => {
await lernaImport(testDir)(externalDir, "--flatten");

expect(await lastCommitInDir(testDir)).toBe("Branch merged");
expect(await pathExists(newFilePath)).toBe(true);
expect(fs.existsSync(newFilePath)).toBe(true);
});

it("imports a repo into the root directory when packages are located there", async () => {
Expand All @@ -94,8 +93,8 @@ describe("ImportCommand", () => {
await lernaImport(testDir)(externalDir);

expect(await lastCommitInDir(testDir)).toBe("myapp-foo init commit");
expect(await pathExists(path.join(testDir, "myapp-foo/old-file"))).toBe(true);
expect(await pathExists(path.join(testDir, "myapp-foo/package.json"))).toBe(true);
expect(fs.existsSync(path.join(testDir, "myapp-foo/old-file"))).toBe(true);
expect(fs.existsSync(path.join(testDir, "myapp-foo/package.json"))).toBe(true);
});

it("supports moved files within the external repo", async () => {
Expand All @@ -108,7 +107,7 @@ describe("ImportCommand", () => {
await lernaImport(testDir)(externalDir);

expect(await lastCommitInDir(testDir)).toBe("Moved old-file to new-file");
expect(await pathExists(newFilePath)).toBe(true);
expect(fs.existsSync(newFilePath)).toBe(true);
});

it("supports filepaths that have spaces within the external repo", async () =>
Expand All @@ -128,8 +127,8 @@ describe("ImportCommand", () => {
}

expect(await lastCommitInDir(testDir)).toBe("Init external commit");
expect(await pathExists(newFilePath)).toBe(true);
expect(await pathExists(newDeepFilePath)).toBe(true);
expect(fs.existsSync(newFilePath)).toBe(true);
expect(fs.existsSync(newDeepFilePath)).toBe(true);
})
));

Expand Down Expand Up @@ -159,8 +158,8 @@ describe("ImportCommand", () => {
}

expect(await lastCommitInDir(testDir)).toBe("rename");
expect(await pathExists(copyFilePath)).toBe(true);
expect(await pathExists(renameFilePath)).toBe(true);
expect(fs.existsSync(copyFilePath)).toBe(true);
expect(fs.existsSync(renameFilePath)).toBe(true);
})
));

Expand Down Expand Up @@ -315,7 +314,7 @@ describe("ImportCommand", () => {
await lernaImport(testDir)(externalDir);

expect(await lastCommitInDir(testDir)).toBe("[ISSUE-10] Moved old-file to new-file");
expect(await pathExists(newFilePath)).toBe(true);
expect(fs.existsSync(newFilePath)).toBe(true);
});
});

Expand All @@ -330,7 +329,7 @@ describe("ImportCommand", () => {
await lernaImport(testDir)(externalDir);

expect(await lastCommitInDir(rootDir)).toBe("Init external commit");
expect(await pathExists(packageJson)).toBe(true);
expect(fs.existsSync(packageJson)).toBe(true);
});
});

Expand All @@ -344,7 +343,7 @@ describe("ImportCommand", () => {
await lernaImport(testDir)(externalDir, "--dest=packages");

expect(await lastCommitInDir(testDir)).toBe("Init external commit");
expect(await pathExists(packageJson)).toBe(true);
expect(fs.existsSync(packageJson)).toBe(true);
});

it("throws error when the package directory does not match with config", async () => {
Expand Down
5 changes: 2 additions & 3 deletions libs/core/src/lib/rimraf-dir.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { existsSync } from "fs";
import log from "npmlog";
import pathExists from "path-exists";
import rimraf from "rimraf";

export async function rimrafDir(dirPath: string) {
log.silly("rimrafDir", dirPath);

// Short-circuit if we don't have anything to do.
const fileExists = await pathExists(dirPath);
if (!fileExists) {
if (!existsSync(dirPath)) {
return;
}

Expand Down
3 changes: 0 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@
"p-reduce": "^2.1.0",
"p-waterfall": "^2.1.1",
"pacote": "^13.6.2",
"path-exists": "^4.0.0",
"pify": "^5.0.0",
"read-cmd-shim": "^3.0.0",
"read-package-json": "^5.0.1",
Expand Down
1 change: 0 additions & 1 deletion packages/legacy-package-management/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
"p-queue": "6.6.2",
"p-waterfall": "2.1.1",
"pacote": "13.6.2",
"path-exists": "4.0.0",
"pify": "5.0.0",
"pretty-format": "29.4.3",
"read-cmd-shim": "3.0.0",
Expand Down
1 change: 0 additions & 1 deletion packages/lerna/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@
"p-reduce": "2.1.0",
"p-waterfall": "2.1.1",
"pacote": "13.6.2",
"path-exists": "4.0.0",
"pify": "5.0.0",
"read-cmd-shim": "3.0.0",
"read-package-json": "5.0.1",
Expand Down

0 comments on commit 904ff29

Please sign in to comment.