puzzle/scripts/fix_image.js
Zutatensuppe e83d3e8d61 rename fn
2021-04-30 20:41:08 +02:00

25 lines
603 B
JavaScript
Executable file

#!/bin/env node
import GameCommon from '../common/GameCommon.js'
import { logger } from '../common/Util.js'
import Game from '../server/Game.js'
const log = logger('fix_image.js')
function fix(gameId) {
Game.loadGameFromFile(gameId)
let changed = false
let imgUrl = GameCommon.getImageUrl(gameId)
if (imgUrl.match(/^\/example-images\//)) {
log.log(`found bad imgUrl: ${imgUrl}`)
imgUrl = imgUrl.replace(/^\/example-images\//, '/uploads/')
GameCommon.setImageUrl(gameId, imgUrl)
changed = true
}
if (changed) {
Game.writeGameToFile(gameId)
}
}
fix(process.argv[2])