npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

is-fs-case-sensitive

v2.0.0

Published

Check whether the file-system is case-sensitive

Readme

is-fs-case-sensitive Latest version Install size

Detect whether the underlying filesystem has case-sensitive file paths. A robust, zero-dependency utility for cross-platform tools.

🤔 Why?

Different operating systems handle filename casing differently:

  • macOS (APFS): Case-insensitive by default, but can be formatted as case-sensitive.
  • Windows (NTFS): Case-insensitive by default, but case-sensitivity can be enabled per-directory.
  • Linux (ext4): Case-sensitive by default.

This distinction is critical for tools like bundlers, linters, or test runners that need to resolve file paths consistently across different environments. This package provides a reliable, runtime check to determine the actual behavior of the filesystem where your code is running.

🚀 Install

npm install is-fs-case-sensitive

👨🏻‍🏫 Examples

Basic Usage

Check the current working directory's filesystem. Results are cached per-directory.

import { isFsCaseSensitive } from 'is-fs-case-sensitive'

// Check current working directory (defaults to process.cwd())
// On a standard macOS or Windows system:
console.log(isFsCaseSensitive())
// => false

// On a standard Linux system:
console.log(isFsCaseSensitive())
// => true

Check Specific Directory

Check case-sensitivity of a specific directory's filesystem.

import { isFsCaseSensitive } from 'is-fs-case-sensitive'

// Check a specific directory
console.log(isFsCaseSensitive('/path/to/directory'))
// => true or false depending on that directory's filesystem

// Different mount points can have different case-sensitivity
console.log(isFsCaseSensitive('/home/user')) // => true (ext4)
console.log(isFsCaseSensitive('/mnt/windows')) // => false (NTFS)

Advanced Usage

You can provide a custom fs implementation and bypass the cache for testing purposes.

import { Volume } from 'memfs'
import { isFsCaseSensitive } from 'is-fs-case-sensitive'

// `memfs` is case-sensitive by default
const customFs = Volume.fromJSON({})

// Pass in directory, custom fs implementation, and disable cache
const isSensitive = isFsCaseSensitive(undefined, customFs, false)

console.log(isSensitive)
// => true

⚙️ How it Works

The check detects case-sensitivity of a specific directory's filesystem using a fast, I/O-free primary method with a reliable fallback.

  1. Primary Check: The function inverts the case of the directory path and checks if the inverted-case version resolves to an existing directory. This is fast, requires no write permissions, and doesn't trigger file watchers.
  2. Fallback Check: If the primary check is inconclusive (e.g., the path has no letters to invert or the directory doesn't exist), it safely writes and immediately deletes a temporary file in that directory. When checking the default working directory and it's not writable, it falls back to the OS temp directory.
  3. Caching: Results are cached per directory. Subsequent calls for the same directory return instantly without re-checking.

[!IMPORTANT] Since different mount points can have different case-sensitivity settings, this package checks the filesystem where the specified directory resides. Always pass the directory you care about to get accurate results for that filesystem.

🛠️ API

isFsCaseSensitive(directoryPath?, fsInstance?, useCache?)

Returns: boolean

Returns true if the filesystem is case-sensitive, false otherwise.

directoryPath

Type: string

Default: process.cwd()

The directory path to check. Different mount points can have different case-sensitivity settings.

When omitted (defaults to current working directory), the function will fall back to checking the OS temp directory if the working directory isn't writable. When explicitly provided, the function will throw an error if the directory isn't accessible or writable.

fsInstance

Type: object with existsSync, writeFileSync, and unlinkSync methods.

Default: Node.js fs module.

An optional filesystem implementation to use. This is primarily intended for testing with mock filesystems like memfs.

useCache

Type: boolean

Default: true

Controls whether the result is cached per directory.

  • true: The check runs once per directory, and results are cached. Subsequent calls for the same directory return instantly.
  • false: The cache is bypassed, and the filesystem check is re-run. This is useful for tests where you need to check different mock filesystems.