UNPKG

@cocalc/project

Version:
22 lines (20 loc) 729 B
"use strict"; /* Read a text file. EXAMPLE: curl -u `cat .smc/secret_token`: -d path=a.txt -d content="bar" http://localhost:`cat .smc/api-server.port`/api/v1/write-text-file */ Object.defineProperty(exports, "__esModule", { value: true }); const util_1 = require("util"); const fs_1 = require("fs"); const server_1 = require("./server"); async function readTextFile({ path }) { const dbg = server_1.client.dbg("read-text-file"); dbg(`path="${path}"`); if (typeof path != "string") { throw Error(`provide the path as a string -- got path="${path}"`); } return (await (0, util_1.promisify)(fs_1.readFile)(path)).toString(); } exports.default = readTextFile; //# sourceMappingURL=read-text-file.js.map