UNPKG

motoko

Version:

Compile and run Motoko smart contracts in Node.js or the browser.

80 lines 2.15 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.file = void 0; function getValidPath(path) { if (typeof path !== 'string') { throw new Error('File path must be a string'); } if (path.startsWith('/')) { path = path.slice(1); } if (path.endsWith('/')) { path = path.slice(0, -1); } return path; } const file = (mo, path) => { path = getValidPath(path); const result = { get path() { return path; }, set path(newPath) { path = newPath; }, // file(subPath) { // subPath = getValidPath(subPath); // return exports.file(`${path}/${subPath}`); // }, clone() { return exports.file(path); }, read() { return mo.read(path); }, write(content) { return mo.write(path, content); }, rename(newPath) { let result = mo.rename(path, newPath); path = newPath; return result; }, delete() { return mo.delete(path); }, list() { return mo.list(path); }, check() { return mo.check(path); }, run() { return mo.run(path); }, candid() { return mo.candid(path); }, wasm(mode) { return mo.wasm(path, mode); }, parseCandid() { return mo.parseCandid(result.read()); }, parseMotoko(enableRecovery) { return mo.parseMotoko(result.read(), enableRecovery); }, parseMotokoWithDeps(enableRecovery) { return mo.parseMotokoWithDeps(path, result.read(), enableRecovery); }, parseMotokoTyped() { return mo.parseMotokoTyped(path); }, parseMotokoTypedWithScopeCache(scopeCache, enableRecovery) { return mo.parseMotokoTypedWithScopeCache(path, scopeCache, enableRecovery); }, }; return result; }; exports.file = file; //# sourceMappingURL=file.js.map