mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 03:00:58 +08:00
34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
const ScreenshotConnector = require('@stencil/core/screenshot/screenshot-connector');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
|
|
class LocalScreenshotConnector extends ScreenshotConnector {
|
|
|
|
async pullMasterImages() {
|
|
const timespan = this.logger.createTimeSpan(`pull master screenshot images started`);
|
|
|
|
const masterFilePaths = (fs.readdirSync(this.masterDir)).map(f => path.join(this.masterDir, f)).filter(f => f.endsWith('.json'));
|
|
const masterScreenshots = masterFilePaths.map(f => JSON.parse(fs.readFileSync(f, 'utf-8')));
|
|
const masterImageNames = masterScreenshots.map(s => s.image);
|
|
const missingImages = masterImageNames.filter(masterImageName => {
|
|
try {
|
|
const masterImagePath = path.join(this.imagesDir, masterImageName);
|
|
fs.accessSync(masterImagePath);
|
|
return false;
|
|
} catch (e) {}
|
|
return true
|
|
});
|
|
|
|
missingImages.forEach(missingImage => {
|
|
const url = missingImage;
|
|
this.logger.info(`downloading: ${url}`);
|
|
});
|
|
|
|
timespan.finish(`pull master screenshot images finished`);
|
|
}
|
|
|
|
}
|
|
|
|
module.exports = LocalScreenshotConnector;
|