UNPKG

@argdown/node

Version:

Async Argdown application for node.js

26 lines 893 B
import defaultsDeep from "lodash.defaultsdeep"; export class StdOutPlugin { constructor(config) { this.name = "StdOutPlugin"; this.prepare = request => { defaultsDeep(this.getSettings(request), this.defaults); }; this.run = (request, response) => { const settings = this.getSettings(request); if (settings.dataKey) { let content = !settings.isRequestData ? response[settings.dataKey] : request[settings.dataKey]; if (content !== undefined) { process.stdout.write(content); } } }; this.defaults = defaultsDeep({}, config, {}); } getSettings(request) { request.stdout = request.stdout || {}; return request.stdout; } } //# sourceMappingURL=StdOutPlugin.js.map