Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

saveScreenshot.js 896B

12345678910111213141516171819
  1. "use strict";
  2. var __importDefault = (this && this.__importDefault) || function (mod) {
  3. return (mod && mod.__esModule) ? mod : { "default": mod };
  4. };
  5. Object.defineProperty(exports, "__esModule", { value: true });
  6. const fs_1 = __importDefault(require("fs"));
  7. const utils_1 = require("../../utils");
  8. async function saveScreenshot(filepath) {
  9. if (typeof filepath !== 'string' || !filepath.endsWith('.png')) {
  10. throw new Error('saveScreenshot expects a filepath of type string and ".png" file ending');
  11. }
  12. const absoluteFilepath = utils_1.getAbsoluteFilepath(filepath);
  13. utils_1.assertDirectoryExists(absoluteFilepath);
  14. const screenBuffer = await this.takeElementScreenshot(this.elementId);
  15. const screenshot = Buffer.from(screenBuffer, 'base64');
  16. fs_1.default.writeFileSync(absoluteFilepath, screenshot);
  17. return screenshot;
  18. }
  19. exports.default = saveScreenshot;