From bb923955b82ecaa9e11c8bd1abe5d9248730e82c Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Wed, 16 Aug 2023 12:04:17 +0200 Subject: [PATCH] style: format with prettier --- .prettierignore | 1 + src/_utils.ts | 10 +++++----- src/api.ts | 10 +++++----- src/package-manager.ts | 8 ++++---- test/index.test.ts | 12 ++++++------ 5 files changed, 21 insertions(+), 20 deletions(-) diff --git a/.prettierignore b/.prettierignore index 6eb0682..706196c 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,2 +1,3 @@ pnpm-lock.yaml .yarn +.pnp.loader.mjs diff --git a/src/_utils.ts b/src/_utils.ts index 49d1444..925bf94 100644 --- a/src/_utils.ts +++ b/src/_utils.ts @@ -8,7 +8,7 @@ import { detectPackageManager } from "./package-manager"; export async function findup( cwd: string, match: (path: string) => T | Promise, - options: Pick = {}, + options: Pick = {} ): Promise { const segments = normalize(cwd).split("/"); @@ -27,7 +27,7 @@ export async function findup( export async function executeCommand( command: string, args: string[], - options: Pick = {}, + options: Pick = {} ): Promise { const { execa } = await import("execa"); const { resolve } = await import("pathe"); @@ -49,7 +49,7 @@ export const NO_PACKAGE_MANAGER_DETECTED_ERROR_MSG = "No package manager auto-detected."; export async function resolveOperationOptions( - options: OperationOptions = {}, + options: OperationOptions = {} ): Promise< NonPartial< Pick @@ -76,7 +76,7 @@ export async function resolveOperationOptions( } export function getWorkspaceArgs( - options: Awaited>, + options: Awaited> ): string[] { if (!options.workspace) { if (options.packageManager.name === "pnpm") { @@ -113,7 +113,7 @@ export function doesDependencyExist( options: Pick< Awaited>, "cwd" | "workspace" - >, + > ) { const require = createRequire(withTrailingSlash(options.cwd)); diff --git a/src/api.ts b/src/api.ts index c826167..bad7285 100644 --- a/src/api.ts +++ b/src/api.ts @@ -15,7 +15,7 @@ import type { OperationOptions } from "./types"; * @param options.packageManager - The package manager info to use (auto-detected). */ export async function installDependencies( - options: Pick = {}, + options: Pick = {} ) { const resolvedOptions = await resolveOperationOptions(options); @@ -38,7 +38,7 @@ export async function installDependencies( */ export async function addDependency( name: string, - options: OperationOptions = {}, + options: OperationOptions = {} ) { const resolvedOptions = await resolveOperationOptions(options); @@ -77,7 +77,7 @@ export async function addDependency( */ export async function addDevDependency( name: string, - options: Omit = {}, + options: Omit = {} ) { await addDependency(name, { ...options, dev: true }); } @@ -95,7 +95,7 @@ export async function addDevDependency( */ export async function removeDependency( name: string, - options: OperationOptions = {}, + options: OperationOptions = {} ) { const resolvedOptions = await resolveOperationOptions(options); @@ -134,7 +134,7 @@ export async function removeDependency( */ export async function ensureDependencyInstalled( name: string, - options: Pick = {}, + options: Pick = {} ) { const resolvedOptions = await resolveOperationOptions(options); diff --git a/src/package-manager.ts b/src/package-manager.ts index 95bb01e..a687740 100644 --- a/src/package-manager.ts +++ b/src/package-manager.ts @@ -52,7 +52,7 @@ const _packageManagers: PackageManager[] = [ export async function detectPackageManager( cwd: string, - options: DetectPackageManagerOptions = {}, + options: DetectPackageManagerOptions = {} ): Promise { const detected = await findup( cwd, @@ -62,7 +62,7 @@ export async function detectPackageManager( const packageJSONPath = join(path, "package.json"); if (existsSync(packageJSONPath)) { const packageJSON = JSON.parse( - await readFile(packageJSONPath, "utf8"), + await readFile(packageJSONPath, "utf8") ); if (packageJSON?.packageManager) { const [name, version = "0.0.0"] = @@ -70,7 +70,7 @@ export async function detectPackageManager( const majorVersion = version.split(".")[0]; const packageManager = _packageManagers.find( - (pm) => pm.name === name && pm.majorVersion === majorVersion, + (pm) => pm.name === name && pm.majorVersion === majorVersion ) || _packageManagers.find((pm) => pm.name === name); return { ...packageManager, @@ -102,7 +102,7 @@ export async function detectPackageManager( }, { includeParentDirs: options.includeParentDirs, - }, + } ); return detected; diff --git a/test/index.test.ts b/test/index.test.ts index 32f1677..e82e785 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -137,7 +137,7 @@ describe("api", () => { if (fixture.name === "empty") { expect( - async () => await executeInstallDependenciesSpy(), + async () => await executeInstallDependenciesSpy() ).rejects.toThrowError(NO_PACKAGE_MANAGER_DETECTED_ERROR_MSG); } else { await executeInstallDependenciesSpy(); @@ -157,7 +157,7 @@ describe("api", () => { if (fixture.name === "empty") { expect( - async () => await executeAddDependencySpy(), + async () => await executeAddDependencySpy() ).rejects.toThrowError(NO_PACKAGE_MANAGER_DETECTED_ERROR_MSG); } else { await executeAddDependencySpy(); @@ -176,7 +176,7 @@ describe("api", () => { if (fixture.name === "empty") { expect( - async () => await executeEnsureDependencyInstalledSpy(), + async () => await executeEnsureDependencyInstalledSpy() ).rejects.toThrowError(NO_PACKAGE_MANAGER_DETECTED_ERROR_MSG); } else { await executeEnsureDependencyInstalledSpy(); @@ -196,7 +196,7 @@ describe("api", () => { if (fixture.name === "empty") { expect( - async () => await executeRemoveDependencySpy(), + async () => await executeRemoveDependencySpy() ).rejects.toThrowError(NO_PACKAGE_MANAGER_DETECTED_ERROR_MSG); } else { await executeRemoveDependencySpy(); @@ -217,7 +217,7 @@ describe("api", () => { if (fixture.name === "empty") { expect( - async () => await executeAddDependencySpy(), + async () => await executeAddDependencySpy() ).rejects.toThrowError(NO_PACKAGE_MANAGER_DETECTED_ERROR_MSG); } else { await executeAddDependencySpy(); @@ -238,7 +238,7 @@ describe("api", () => { if (fixture.name === "empty") { expect( - async () => await executeRemoveDependencySpy(), + async () => await executeRemoveDependencySpy() ).rejects.toThrowError(NO_PACKAGE_MANAGER_DETECTED_ERROR_MSG); } else { await executeRemoveDependencySpy();