Skip to content

Commit 43a5812

Browse files
used consts
1 parent b36d5ac commit 43a5812

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/commander/upload.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import createBuild from '../tasks/createBuild.js';
1010
import uploadScreenshots from '../tasks/uploadScreenshots.js';
1111
import finalizeBuild from '../tasks/finalizeBuild.js';
1212

13+
const ZIP_EXTENSION = '.zip';
1314
const command = new Command();
1415

1516
command
@@ -32,7 +33,7 @@ command
3233
return;
3334
}
3435

35-
if (path.extname(directory).toLowerCase() === '.zip') {
36+
if (path.extname(directory).toLowerCase() === ZIP_EXTENSION) {
3637
ctx.log.debug(`Zips are not accepted. ${directory}`)
3738
console.log(`Error: The provided directory ${directory} is a zip file. Zips are not accepted.`);
3839
return;

src/lib/screenshot.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ import * as utils from "./utils.js"
66
import constants from './constants.js'
77
import chalk from 'chalk';
88

9+
const magicNumbers = [
10+
{ ext: 'jpg', magic: Buffer.from([0xFF, 0xD8, 0xFF]) },
11+
{ ext: 'jpeg', magic: Buffer.from([0xFF, 0xD8, 0xFF]) },
12+
{ ext: 'png', magic: Buffer.from([0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A]) },
13+
];
14+
915
async function captureScreenshotsForConfig(
1016
ctx: Context,
1117
browsers: Record<string, Browser>,
@@ -166,11 +172,6 @@ function getImageDimensions(filePath: string): { width: number, height: number }
166172
}
167173

168174
function isImage(buffer: Buffer): boolean {
169-
const magicNumbers = [
170-
{ ext: 'jpg', magic: Buffer.from([0xFF, 0xD8, 0xFF]) },
171-
{ ext: 'jpeg', magic: Buffer.from([0xFF, 0xD8, 0xFF]) },
172-
{ ext: 'png', magic: Buffer.from([0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A]) },
173-
];
174175

175176
return magicNumbers.some(magic => buffer.slice(0, magic.magic.length).equals(magic.magic));
176177
}

0 commit comments

Comments
 (0)