Skip to content

Commit

Permalink
Fix argument parsing and update dependencies
Browse files Browse the repository at this point in the history
- Resolved argument parsing issues with `--config` and `--label` options, ensuring proper handling of command-line arguments.
- Applied Prettier formatting across the codebase for consistent coding styles.
- Updated project dependencies to their latest versions for improved security and performance.

These changes enhance the tool's reliability, maintainability, and user experience.

Ref: #31
  • Loading branch information
jacobwi committed Mar 17, 2024
1 parent e60ccc5 commit 4c9aa5a
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/cli/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
*--------------------------------------------------------*/

import { existsSync, promises as fs } from 'fs';
import { dirname, isAbsolute, join } from 'path';

import { dirname, extname, isAbsolute, join, resolve as resolvePath } from 'path';
import { pathToFileURL } from 'url';
import {
IConfigurationWithGlobalOptions,
Expand Down Expand Up @@ -52,7 +53,11 @@ export async function loadDefaultConfigFile(): Promise<ResolvedTestConfiguration

/** Loads a specific config file by the path, throwing if loading fails. */
export async function tryLoadConfigFile(path: string): Promise<ResolvedTestConfiguration> {
const ext = path.split('.').pop()!;
if (!isAbsolute(path)) {
path = resolvePath(path);
}

const ext = extname(path).slice(1);
if (!configFileRules.hasOwnProperty(ext)) {
throw new CliExpectedError(
`I don't know how to load the extension '${ext}'. We can load: ${Object.keys(
Expand Down Expand Up @@ -89,7 +94,8 @@ export class ResolvedTestConfiguration implements IConfigurationWithGlobalOption
public static async load(config: IConfigurationWithGlobalOptions, path: string) {
// Resolve all mocha `require` locations relative to the configuration file,
// since these are otherwise relative to the runner which is opaque to the user.
const dir = dirname(path);
const resolved = resolvePath(path);
const dir = dirname(resolved);
for (const test of config.tests) {
if (test.mocha?.require) {
test.mocha.require = await Promise.all(
Expand Down

0 comments on commit 4c9aa5a

Please sign in to comment.