← All procedures

fs.exists

Check if file or directory exists

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

From the command line

$ mark fs exists --path <string>

As data, in a program

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

Input

FieldTypeRequiredDefaultDescription
pathstringyesPath to check

Output

The schema does not list fields (object | object).

JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "path": {
        "type": "string",
        "description": "Path to check"
      }
    },
    "required": [
      "path"
    ]
  },
  "output": {
    "anyOf": [
      {
        "type": "object",
        "properties": {
          "exists": {
            "type": "boolean",
            "const": false,
            "description": "The path does not exist"
          }
        },
        "required": [
          "exists"
        ],
        "additionalProperties": {}
      },
      {
        "type": "object",
        "properties": {
          "exists": {
            "type": "boolean",
            "const": true,
            "description": "The path exists"
          },
          "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 path"
          }
        },
        "required": [
          "exists",
          "stats"
        ],
        "additionalProperties": {}
      }
    ]
  }
}