← All procedures

fs.readdir

Read directory contents

CLI
Package
@procedures/fs · README
Path
["fs","readdir"]
CLI
mark fs readdir --path <string>
As data
{"$proc":["fs","readdir"],"input":{}}

Use it

In TypeScript

import { Client, LocalTransport, PROCEDURE_REGISTRY } from "@procedures/client";
import "@procedures/fs"; // registers its procedures

const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["fs","readdir"], { path: "<path>" });
console.log(JSON.stringify(result));

From the command line

$ mark fs readdir --path <string>

As data, in a program

{ "$proc": ["fs", "readdir"], "input": { "path": "<path>" } }

Input

FieldTypeRequiredDefaultDescription
pathstringyesPath of directory to read
recursivebooleannofalseRead subdirectories recursively (default: false)
includeStatsbooleannofalseInclude file stats with each entry (default: false)

Output

FieldTypeRequiredDefaultDescription
pathstringyesThe path of the folder
entriesobject[]yesThe entries of the folder
JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "path": {
        "type": "string",
        "description": "Path of directory to read"
      },
      "recursive": {
        "default": false,
        "description": "Read subdirectories recursively (default: false)",
        "type": "boolean"
      },
      "includeStats": {
        "default": false,
        "description": "Include file stats with each entry (default: false)",
        "type": "boolean"
      }
    },
    "required": [
      "path"
    ]
  },
  "output": {
    "type": "object",
    "properties": {
      "path": {
        "type": "string",
        "description": "The path of the folder"
      },
      "entries": {
        "type": "array",
        "items": {
          "type": "object",
          "properties": {
            "name": {
              "type": "string",
              "description": "The name of the entry"
            },
            "path": {
              "type": "string",
              "description": "The full path of the entry"
            },
            "type": {
              "type": "string",
              "enum": [
                "file",
                "directory",
                "other"
              ],
              "description": "file, directory or other"
            },
            "stats": {
              "description": "The stats, with includeStats",
              "type": "object",
              "properties": {
                "path": {
                  "type": "string",
                  "description": "The path"
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "file",
                    "directory",
                    "other"
                  ],
                  "description": "file, directory or other"
                },
                "size": {
                  "type": "number",
                  "description": "The size, in bytes"
                },
                "mtime": {
                  "type": "string",
                  "description": "The time of the last change (ISO 8601)"
                },
                "ctime": {
                  "type": "string",
                  "description": "The time of the last status change (ISO 8601)"
                },
                "atime": {
                  "type": "string",
                  "description": "The time of the last access (ISO 8601)"
                },
                "mode": {
                  "type": "number",
                  "description": "The mode bits (type and permissions)"
                }
              },
              "required": [
                "path",
                "type",
                "size",
                "mtime",
                "ctime",
                "atime",
                "mode"
              ],
              "additionalProperties": {}
            }
          },
          "required": [
            "name",
            "path",
            "type"
          ],
          "additionalProperties": {}
        },
        "description": "The entries of the folder"
      }
    },
    "required": [
      "path",
      "entries"
    ],
    "additionalProperties": {}
  }
}