Skip to content

create-fs

The file system used by create. 🗄️

Terminal window
npm i create-fs

The separate create-fs package includes types and utility functions for the file system used in Runtime > Creations > files.

This file system is a simplified abstraction over the lower-level APIs in Node.js and other platforms. APIs and data are optimized for simplicity and ease of use, rather than completeness.

For example, given a structure like:

/
└── README.md
└── src
└── index.ts

create-fs would represent that structure with an object like:

{
"README.md": "...",
"src": {
"index.ts": "..."
}
}

APIs

intakeFromDirectory

Given a directory path, reads in the directory as to the create-fs directory structure.

import { intakeFromDirectory } from "create-fs";
// Result: { "index.ts": "..." }
await intakeFromDirectory("src");

Parameters:

  1. directoryPath: string (required)
  2. settings: IntakeFromDirectorySettings (optional):

exclude

An optional regular expression to filter out directory children.

For example, you may want to avoid .git and node_modules directories:

import { intakeFromDirectory } from "create-fs";
// Result: { README.md: "...", src: { "index.ts": "..." }}
await intakeFromDirectory(".", {
exclude: /node_modules|^\.git$/,
});
Made with 💝 in Boston by Josh Goldberg.