Create, read, modify, and watch files and directories in your Replit App using the filesystem API methods and types.
fs.readFile
path
and returns an object containing the contents, or an object containing an error if there was one. Required permissions: read
.
fs.writeFile
path
with the contents content
. Required permissions: read
, write-exec
.
fs.readDir
path
and returns an object containing the contents, or an object containing an error if there was one. Required permissions: read
.
fs.createDir
read
, write-exec
.
fs.deleteFile
read
, write-exec
.
fs.deleteDir
read
, write-exec
.
fs.move
from
to to
. Required permissions: read
, write-exec
.
fs.copyFile
from
to to
. Required permissions: read
, write-exec
.
fs.watchFile
path
for changes with the provided listeners
. Returns a dispose method which cleans up the listeners. Required permissions: read
.
fs.watchDir
path
. Returns a dispose method which cleans up the listeners. Required permissions: read
.
fs.watchTextFile
path
for changes with the provided listeners
. Returns a dispose method which cleans up the listeners.
Use this for watching text files, and receive changes as versioned operational transform (OT) operations annotated with their source.
Required permissions: read
.
Property | Type |
---|
Property | Type |
---|---|
eventType | Delete |
node | FsNode |
Property | Type |
---|---|
filename | string |
type | FsNodeType |
Property | Type |
---|---|
path | string |
type | FsNodeType |
Property | Type |
---|
Property | Type |
---|---|
eventType | Move |
node | FsNode |
to | string |
Property | Type |
---|---|
from | number |
insert? | string |
to? | number |
Property | Type |
---|---|
changes | TextChange[] |
latestContent | string |
Property | Type |
---|---|
getLatestContent | GetLatestContent |
initialContent | string |
writeChange | WriteChange |
Property | Type |
---|---|
onChange | WatchDirOnChangeListener |
onError | WatchDirOnErrorListener |
onMoveOrDelete? | WatchDirOnMoveOrDeleteListener |
T extends string | Blob = string
>
Property | Type |
---|---|
onChange | WatchFileOnChangeListener<T> |
onError? | WatchFileOnErrorListener |
onMoveOrDelete? | WatchFileOnMoveOrDeleteListener |
Property | Type |
---|---|
onChange? | WatchTextFileOnChangeListener |
onError? | WatchTextFileOnErrorListener |
onMoveOrDelete? | WatchTextFileOnMoveOrDeleteListener |
onReady | WatchTextFileOnReadyListener |