← All procedures
fs.write
Write content to file
CLI- Package
- @procedures/fs · README
- Path
["fs","write"]- CLI
mark fs write --path <string> --content <string>- As data
{"$proc":["fs","write"],"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","write"], { path: "<path>", content: "<content>" });
console.log(JSON.stringify(result));From the command line
$ mark fs write --path <string> --content <string>
As data, in a program
{
"$proc": ["fs", "write"],
"input": { "path": "<path>", "content": "<content>" }
}Input
| Field | Type | Required | Default | Description |
|---|
path | string | yes | | Path to file to write |
content | string | yes | | Content to write |
encoding | string | no | "utf8" | File encoding (default: utf8) |
mode | "write" | "append" | no | "write" | Write mode: write (overwrite) or append (default: write) |
Output
| Field | Type | Required | Default | Description |
|---|
path | string | yes | | The path of the file |
bytesWritten | number | yes | | The number of bytes written |
JSON Schemas
{
"input": {
"type": "object",
"properties": {
"path": {
"type": "string",
"description": "Path to file to write"
},
"content": {
"type": "string",
"description": "Content to write"
},
"encoding": {
"default": "utf8",
"description": "File encoding (default: utf8)",
"type": "string"
},
"mode": {
"default": "write",
"description": "Write mode: write (overwrite) or append (default: write)",
"type": "string",
"enum": [
"write",
"append"
]
}
},
"required": [
"path",
"content"
]
},
"output": {
"type": "object",
"properties": {
"path": {
"type": "string",
"description": "The path of the file"
},
"bytesWritten": {
"type": "number",
"description": "The number of bytes written"
}
},
"required": [
"path",
"bytesWritten"
],
"additionalProperties": {}
}
}