← All procedures

fs.read

Read file contents

CLI
Package
@procedures/fs · README
Path
["fs","read"]
CLI
mark fs read --path <string>
As data
{"$proc":["fs","read"],"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","read"], { path: "<path>" });
console.log(JSON.stringify(result));

From the command line

$ mark fs read --path <string>

As data, in a program

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

Input

FieldTypeRequiredDefaultDescription
pathstringyesPath to file to read
encodingstringno"utf8"File encoding (default: utf8)

Output

FieldTypeRequiredDefaultDescription
contentstringyesThe content of the file
pathstringyesThe path of the file
statsobjectyesThe stats of the file
JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "path": {
        "type": "string",
        "description": "Path to file to read"
      },
      "encoding": {
        "default": "utf8",
        "description": "File encoding (default: utf8)",
        "type": "string"
      }
    },
    "required": [
      "path"
    ]
  },
  "output": {
    "type": "object",
    "properties": {
      "content": {
        "type": "string",
        "description": "The content of the file"
      },
      "path": {
        "type": "string",
        "description": "The path of the file"
      },
      "stats": {
        "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": {},
        "description": "The stats of the file"
      }
    },
    "required": [
      "content",
      "path",
      "stats"
    ],
    "additionalProperties": {}
  }
}