Path fixes for all environments, npm run format, removed redundant imports

This commit is contained in:
2024-10-01 00:10:30 +02:00
parent 4cbd62cbb0
commit ce1708a55e
24 changed files with 82 additions and 87 deletions

View File

@ -1,15 +1,15 @@
import path from 'path'
import fs from 'fs'
import sharp from 'sharp'
import { commandLogger } from '../utilities/logger'
import { Server } from 'socket.io'
import { getPublicPath } from '../utilities/utilities'
export default class TilesCommand {
constructor(private readonly io: Server) {}
public async execute(): Promise<void> {
// Get all tiles
const tilesDir = path.join(process.cwd(), 'public', 'tiles')
const tilesDir = getPublicPath('tiles')
const tiles = fs.readdirSync(tilesDir).filter((file) => file.endsWith('.png'))
// Create output directory if it doesn't exist
@ -19,14 +19,14 @@ export default class TilesCommand {
for (const tile of tiles) {
// Check if tile is already 66x34
const metadata = await sharp(path.join(tilesDir, tile)).metadata()
const metadata = await sharp(getPublicPath('tiles', tile)).metadata()
if (metadata.width === 66 && metadata.height === 34) {
commandLogger.info(`Tile ${tile} already processed`)
continue
}
const inputPath = path.join(tilesDir, tile)
const outputPath = path.join(tilesDir, tile)
const inputPath = getPublicPath('tiles', tile)
const outputPath = getPublicPath('tiles', tile)
try {
await sharp(inputPath)