UNPKG

@atomist/automation-client

Version:
49 lines 1.45 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const AbstractFile_1 = require("../support/AbstractFile"); /** * In memory File implementation. Useful in testing * and to back quasi-synchronous operations. Do not use * for very large files. */ class InMemoryFile extends AbstractFile_1.AbstractFile { constructor(path, content) { super(); this.path = path; this.content = content; this.initialPath = path; this.initialContent = content; } getContentSync() { return this.content; } setContentSync(content) { this.content = content; return this; } setContent(content) { return Promise.resolve(this.setContentSync(content)); } getContent() { return Promise.resolve(this.getContentSync()); } setPath(path) { this.path = path; return Promise.resolve(this); } get dirty() { return this.initialContent !== this.getContentSync() || this.initialPath !== this.path || super.dirty; } isExecutable() { throw new Error("isExecutable is not implemented here"); } isReadable() { throw new Error("isReadable is not implemented here"); } isBinary() { // InMemoryFile does not presently support binary files return Promise.resolve(false); } } exports.InMemoryFile = InMemoryFile; //# sourceMappingURL=InMemoryFile.js.map