# fs-generate

> Utilities to set up file system structures (directories, files, and symlinks)

Latest version **1.11.4** (published 2026-09-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install fs-generate
pnpm add fs-generate
yarn add fs-generate
bun add fs-generate
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.11.4 |
| Published | 2026-09-12 |
| First published | 2015-12-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=0.8 |
| Dependencies | 5 |
| Unpacked size | 56.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Kevin Malakoff |
| Maintainers | kmalakoff |
| Keywords | fs, generate, fixtures |

## Links

- npm: https://www.npmjs.com/package/fs-generate
- Repository: https://github.com/kmalakoff/fs-generate
- Homepage: https://github.com/kmalakoff/fs-generate#readme
- Issues: https://github.com/kmalakoff/fs-generate/issues
- npm.io page: https://npm.io/package/fs-generate

## Dependencies (5)

- [queue-cb](https://npm.io/package/queue-cb.md) ^1.0.0
- [fs.realpath](https://npm.io/package/fs.realpath.md) ^1.0.0
- [graceful-fs](https://npm.io/package/graceful-fs.md) ^4.2.11
- [mkdirp-classic](https://npm.io/package/mkdirp-classic.md) ^0.5.2
- [fs-remove-compat](https://npm.io/package/fs-remove-compat.md) ^1.0.0

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 1.11.4 (latest) — 2026-09-12
- 1.11.3 — 2026-05-26
- 1.11.2 — 2026-05-26
- 1.11.1 — 2025-12-27
- 1.11.0 — 2025-12-18
- 1.10.11 — 2025-12-15
- 1.10.10 — 2025-12-12
- 1.10.9 — 2025-12-12
- 1.10.8 — 2025-12-04
- 1.10.7 — 2025-12-04
- 1.10.6 — 2025-12-04
- 1.10.5 — 2025-12-03
- 1.10.4 — 2025-11-06
- 1.10.3 — 2025-10-21
- 1.10.2 — 2025-10-21
- … 46 more at https://npm.io/package/fs-generate/versions

## README

# fs-generate

Utilities to create file system structures containing directories, files, hard
links, and symbolic links.

```sh
npm install fs-generate
```

Provide an object with forward slashes-delimited path keys describing the desired directory structure and it will be created for you.

It updates existing entries to match the requested structure. It does not
remove entries that are not in the structure.

## Example

Save this as a CommonJS `.cjs` file:

```js
const path = require('path');
const generate = require('fs-generate');

var structure = {
  'file1': 'a',
  'file2': 'b',
  'filesymlink1': '~dir3/dir4/file1', // symbolic link starts with ~
  'dir1': null,
  'dir2/file1': 'c',
  'dir2/file2': 'd',
  'dir3/filesymlink2': '~dir2/file1', // symbolic link starts with ~
  'dir3/filelink2': ':dir2/file1', // hard link starts with :
  'dir3/dir4/file1': 'e',
  'dir3/dir4/dir5': null,
  'dir3/dir4/dirsymlink1': '~dir2', // symlink starts with ~
};

generate(path.join(__dirname, 'dest'), structure, function (error) {
  if (error) throw error;
  console.log('Created dest');
});

/*
- dest
  - file1
  - file2
  - filesymlink1 (symlink to dir3/dir4/file1)
  - dir1
  - dir2
    - file1
    - file2
  - dir3
    - filesymlink2 (symlink to dir2/file1)
    - filelink2 (hard link to dir2/file1)
    - dir4
      - file1
      - dir5
      - dirsymlink1 (symlink to dir2)
*/

```

The function also returns a promise when you omit the callback: `await
generate(destination, structure)`.

---
_Source: https://npm.io/package/fs-generate · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
