Skip to content

Commit

Permalink
chore: apply automated lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
autofix-ci[bot] authored Nov 22, 2024
1 parent 9bee93d commit 4659623
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
13 changes: 8 additions & 5 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import { resolve } from "pathe";
import { consola } from "consola";
import { name, version, description } from "../package.json";
import { addDependency, installDependencies, removeDependency } from "./api";
import { detectPackageManager, detectRuntimePackageManager } from "./package-manager";
import {
detectPackageManager,
detectRuntimePackageManager,
} from "./package-manager";

Check warning on line 10 in src/cli.ts

View check run for this annotation

Codecov / codecov/patch

src/cli.ts#L10

Added line #L10 was not covered by tests

const operationArgs = {
cwd: {
Expand Down Expand Up @@ -99,16 +102,16 @@ const detectRunner = defineCommand({
description: "Detect the current package runner using runtime checks",
},
run: () => {
const packageManager = detectRuntimePackageManager()
const packageManager = detectRuntimePackageManager();
if (!packageManager) {
consola.error(`Cannot detect package runner`);
return process.exit(1);
}
consola.log(
`Detected package runner \`${packageManager.name}@${packageManager.version}\``,
);
}
})
},
});

Check warning on line 114 in src/cli.ts

View check run for this annotation

Codecov / codecov/patch

src/cli.ts#L100-L114

Added lines #L100 - L114 were not covered by tests

const main = defineCommand({
meta: {
Expand All @@ -125,7 +128,7 @@ const main = defineCommand({
uninstall: remove,
un: remove,
detect,
'detect-runner': detectRunner
"detect-runner": detectRunner,

Check warning on line 131 in src/cli.ts

View check run for this annotation

Codecov / codecov/patch

src/cli.ts#L131

Added line #L131 was not covered by tests
},
});

Expand Down
31 changes: 16 additions & 15 deletions src/package-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ export type DetectPackageManagerOptions = {

/**
* Weather to ignore runtime checks to detect package manager or script runner
*/
*/
ignoreRuntime?: boolean;

/**
* Whether to ignore argv[1] to detect package manager or script runner, implied if `ignoreRuntimeChecks` is `true`
*/
* Whether to ignore argv[1] to detect package manager or script runner, implied if `ignoreRuntimeChecks` is `true`
*/
ignoreArgv?: boolean;
};

Expand All @@ -43,35 +43,35 @@ export const packageManagers: PackageManager[] = [
name: "npm",
command: "npm",
lockFile: "package-lock.json",
packageRunner: "npx"
packageRunner: "npx",
},
{
name: "pnpm",
command: "pnpm",
lockFile: "pnpm-lock.yaml",
files: ["pnpm-workspace.yaml"],
packageRunner: "pnpm dlx"
packageRunner: "pnpm dlx",
},
{
name: "bun",
command: "bun",
lockFile: ["bun.lockb", "bun.lock"],
packageRunner: "bunx"
packageRunner: "bunx",
},
{
name: "yarn",
command: "yarn",
majorVersion: "1",
lockFile: "yarn.lock",
packageRunner: undefined
packageRunner: undefined,
},
{
name: "yarn",
command: "yarn",
majorVersion: "3",
lockFile: "yarn.lock",
files: [".yarnrc.yml"],
packageRunner: "yarn dlx"
packageRunner: "yarn dlx",
},
] as const;

Expand Down Expand Up @@ -139,18 +139,20 @@ export async function detectPackageManager(
);

if (!detected && !options.ignoreRuntime) {
return detectRuntimePackageManager(options)
return detectRuntimePackageManager(options);
}

Check warning on line 143 in src/package-manager.ts

View check run for this annotation

Codecov / codecov/patch

src/package-manager.ts#L142-L143

Added lines #L142 - L143 were not covered by tests

return detected;
}

export function detectRuntimePackageManager(options: DetectPackageManagerOptions = {}): PackageManager | undefined {
const userAgent = env['npm_config_user_agent']
export function detectRuntimePackageManager(
options: DetectPackageManagerOptions = {},
): PackageManager | undefined {
const userAgent = env["npm_config_user_agent"];

Check warning on line 151 in src/package-manager.ts

View check run for this annotation

Codecov / codecov/patch

src/package-manager.ts#L149-L151

Added lines #L149 - L151 were not covered by tests

const engine = userAgent?.split(' ')?.[0] ?? ''
const engine = userAgent?.split(" ")?.[0] ?? "";

Check warning on line 153 in src/package-manager.ts

View check run for this annotation

Codecov / codecov/patch

src/package-manager.ts#L153

Added line #L153 was not covered by tests

const [name, version = '0.0.0'] = engine.split('/')
const [name, version = "0.0.0"] = engine.split("/");

Check warning on line 155 in src/package-manager.ts

View check run for this annotation

Codecov / codecov/patch

src/package-manager.ts#L155

Added line #L155 was not covered by tests

if (name) {
const majorVersion = version.split(".")[0];
Expand Down Expand Up @@ -181,5 +183,4 @@ export function detectRuntimePackageManager(options: DetectPackageManagerOptions
}
}
}

}
}

0 comments on commit 4659623

Please sign in to comment.