mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
Ensure no deprecated Node.js core API's are used in Kibana. This is achieved by throwing an error in either development mode or in CI if one of the deprecated API's is called, and as such, new PR's should no longer be able to be merged if they use deprecated API's. Some of these API's (like the `Buffer` constructor`) is a security risk.
This commit is contained in:
parent
dfc0612f26
commit
995a914f63
33 changed files with 638 additions and 207 deletions
|
@ -17,14 +17,12 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import bluebird, {
|
||||
fromNode,
|
||||
promisify,
|
||||
} from 'bluebird';
|
||||
import bluebird, { promisify } from 'bluebird';
|
||||
import Handlebars from 'handlebars';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import imageDiff from 'image-diff';
|
||||
import { PNG } from 'pngjs';
|
||||
import pixelmatch from 'pixelmatch';
|
||||
import moment from 'moment';
|
||||
import SimpleGit from 'simple-git';
|
||||
|
||||
|
@ -110,17 +108,23 @@ async function compareScreenshots() {
|
|||
screenshot
|
||||
);
|
||||
|
||||
// Diff the images asynchronously.
|
||||
const diffResult = await fromNode((cb) => {
|
||||
imageDiff.getFullResult({
|
||||
actualImage: sessionImagePath,
|
||||
expectedImage: baselineImagePath,
|
||||
diffImage: diffImagePath,
|
||||
shadow: true,
|
||||
}, cb);
|
||||
});
|
||||
const sessionImage = PNG.sync.read(await fs.promises.readFile(sessionImagePath));
|
||||
const baselineImage = PNG.sync.read(await fs.promises.readFile(baselineImagePath));
|
||||
const { width, height } = sessionImage;
|
||||
const diff = new PNG({ width, height });
|
||||
|
||||
const change = diffResult.percentage;
|
||||
const numDiffPixels = pixelmatch(
|
||||
sessionImage.data,
|
||||
baselineImage.data,
|
||||
diff.data,
|
||||
width,
|
||||
height,
|
||||
{ threshold: 0 }
|
||||
);
|
||||
|
||||
await fs.promises.writeFile(diffImagePath, PNG.sync.write(diff));
|
||||
|
||||
const change = numDiffPixels / (width * height);
|
||||
const changePercentage = (change * 100).toFixed(2);
|
||||
console.log(`(${changePercentage}%) ${screenshot}`);
|
||||
comparison.percentage = changePercentage;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue