Skip to content

Commit

Permalink
refactor: update options type imports and create a new options type d…
Browse files Browse the repository at this point in the history
…efinition file
  • Loading branch information
mceachen committed Jan 5, 2025
1 parent b9cd9da commit 18201b2
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 70 deletions.
2 changes: 1 addition & 1 deletion src/exports.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// src/exports.ts

import type { HideMethod, SetHiddenResult } from "./hidden.js";
import type { Options } from "./options.js";
import {
IncludeSystemVolumesDefault,
LinuxMountTablePathsDefault,
Expand All @@ -19,6 +18,7 @@ import type {
import type { SystemVolumeConfig } from "./system_volume.js";
import type { HiddenMetadata } from "./types/hidden_metadata.js";
import type { MountPoint } from "./types/mount_point.js";
import type { Options } from "./types/options.js";
import type { VolumeMetadata } from "./types/volume_metadata.js";
import type { VolumeHealthStatus } from "./volume_health_status.js";
import { VolumeHealthStatuses } from "./volume_health_status.js";
Expand Down
3 changes: 2 additions & 1 deletion src/linux/mount_points.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import { readFile } from "node:fs/promises";
import { debug } from "../debuglog.js";
import { toError, WrappedError } from "../error.js";
import { compactValues } from "../object.js";
import { optionsWithDefaults, type Options } from "../options.js";
import { optionsWithDefaults } from "../options.js";
import { isMountPoint, type MountPoint } from "../types/mount_point.js";
import type { NativeBindingsFn } from "../types/native_bindings.js";
import type { Options } from "../types/options.js";
import { MountEntry, mountEntryToMountPoint, parseMtab } from "./mtab.js";

export async function getLinuxMountPoints(
Expand Down
54 changes: 1 addition & 53 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,59 +3,7 @@
import { availableParallelism } from "node:os";
import { compactValues, isObject } from "./object.js";
import { isWindows } from "./platform.js";

/**
* Configuration options for filesystem operations.
*
* @see {@link optionsWithDefaults} for creating an options object with default values
* @see {@link OptionsDefault} for the default values
*/
export interface Options {
/**
* Timeout in milliseconds for filesystem operations.
*
* Disable timeouts by setting this to 0.
*
* @see {@link TimeoutMsDefault}.
*/
timeoutMs: number;

/**
* Maximum number of concurrent filesystem operations.
*
* Defaults to {@link https://nodejs.org/api/os.html#osavailableparallelism | availableParallelism}.
*/
maxConcurrency: number;

/**
* On Linux and macOS, mount point pathnames that matches any of these glob
* patterns will have {@link MountPoint.isSystemVolume} set to true.
*
* @see {@link SystemPathPatternsDefault} for the default value
*/
systemPathPatterns: string[];

/**
* On Linux and macOS, volumes whose filesystem matches any of these strings
* will have {@link MountPoint.isSystemVolume} set to true.
*
* @see {@link SystemFsTypesDefault} for the default value
*/
systemFsTypes: string[];

/**
* On Linux, use the first mount point table in this array that is readable.
*
* @see {@link LinuxMountTablePathsDefault} for the default values
*/
linuxMountTablePaths: string[];

/**
* Should system volumes be included in result arrays? Defaults to true on
* Windows and false elsewhere.
*/
includeSystemVolumes: boolean;
}
import type { Options } from "./types/options.js";

/**
* Default timeout in milliseconds for {@link Options.timeoutMs}.
Expand Down
7 changes: 2 additions & 5 deletions src/system_volume.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@

import { debug } from "./debuglog.js";
import { compileGlob } from "./glob.js";
import {
Options,
SystemFsTypesDefault,
SystemPathPatternsDefault,
} from "./options.js";
import { SystemFsTypesDefault, SystemPathPatternsDefault } from "./options.js";
import { normalizePath } from "./path.js";
import { isWindows } from "./platform.js";
import { isNotBlank } from "./string.js";
import type { MountPoint } from "./types/mount_point.js";
import type { Options } from "./types/options.js";

/**
* Configuration for system volume detection
Expand Down
2 changes: 1 addition & 1 deletion src/test-utils/assert.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
// src/test-utils/assert.ts
import { isMacOS } from "../platform.js";
import type { VolumeMetadata } from "../volume_metadata.js";
import type { VolumeMetadata } from "../types/volume_metadata.js";

/**
* Asserts that the given metadata object has valid filesystem metadata
Expand Down
6 changes: 3 additions & 3 deletions src/types/native_bindings.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// src/types/native_bindings.ts

import { MountPoint } from "../mount_point.js";
import type { Options } from "../options.js";
import type { VolumeMetadata } from "../volume_metadata.js";
import type { MountPoint } from "./mount_point.js";
import type { Options } from "./options.js";
import type { VolumeMetadata } from "./volume_metadata.js";

export interface NativeBindings {
/**
Expand Down
54 changes: 54 additions & 0 deletions src/types/options.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// src/types/options.ts

/**
* Configuration options for filesystem operations.
*
* @see {@link optionsWithDefaults} for creating an options object with default values
* @see {@link OptionsDefault} for the default values
*/
export interface Options {
/**
* Timeout in milliseconds for filesystem operations.
*
* Disable timeouts by setting this to 0.
*
* @see {@link TimeoutMsDefault}.
*/
timeoutMs: number;

/**
* Maximum number of concurrent filesystem operations.
*
* Defaults to {@link https://nodejs.org/api/os.html#osavailableparallelism | availableParallelism}.
*/
maxConcurrency: number;

/**
* On Linux and macOS, mount point pathnames that matches any of these glob
* patterns will have {@link MountPoint.isSystemVolume} set to true.
*
* @see {@link SystemPathPatternsDefault} for the default value
*/
systemPathPatterns: string[];

/**
* On Linux and macOS, volumes whose filesystem matches any of these strings
* will have {@link MountPoint.isSystemVolume} set to true.
*
* @see {@link SystemFsTypesDefault} for the default value
*/
systemFsTypes: string[];

/**
* On Linux, use the first mount point table in this array that is readable.
*
* @see {@link LinuxMountTablePathsDefault} for the default values
*/
linuxMountTablePaths: string[];

/**
* Should system volumes be included in result arrays? Defaults to true on
* Windows and false elsewhere.
*/
includeSystemVolumes: boolean;
}
7 changes: 2 additions & 5 deletions src/volume_metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ import {
mountEntryToPartialVolumeMetadata,
} from "./linux/mtab.js";
import { compactValues } from "./object.js";
import {
IncludeSystemVolumesDefault,
type Options,
optionsWithDefaults,
} from "./options.js";
import { IncludeSystemVolumesDefault, optionsWithDefaults } from "./options.js";
import { normalizePath } from "./path.js";
import { isLinux, isWindows } from "./platform.js";
import { extractRemoteInfo, isRemoteFsType } from "./remote_info.js";
Expand All @@ -24,6 +20,7 @@ import type {
GetVolumeMetadataOptions,
NativeBindingsFn,
} from "./types/native_bindings.js";
import type { Options } from "./types/options.js";
import type { VolumeMetadata } from "./types/volume_metadata.js";
import { parseUNCPath } from "./unc.js";
import { extractUUID } from "./uuid.js";
Expand Down
2 changes: 1 addition & 1 deletion src/volume_mount_points.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { mapConcurrent, withTimeout } from "./async.js";
import { debug } from "./debuglog.js";
import { getLinuxMountPoints } from "./linux/mount_points.js";
import { compactValues } from "./object.js";
import { Options } from "./options.js";
import { isMacOS, isWindows } from "./platform.js";
import {
isBlank,
Expand All @@ -16,6 +15,7 @@ import {
import { assignSystemVolume, SystemVolumeConfig } from "./system_volume.js";
import type { MountPoint } from "./types/mount_point.js";
import type { NativeBindingsFn } from "./types/native_bindings.js";
import type { Options } from "./types/options.js";
import { directoryStatus } from "./volume_health_status.js";

export type GetVolumeMountPointOptions = Partial<
Expand Down

0 comments on commit 18201b2

Please sign in to comment.