From 852aa28f1c4a8a6224eee0161baa4b3ba7ccef68 Mon Sep 17 00:00:00 2001 From: Protean Productions Date: Wed, 17 Apr 2024 05:21:58 +0200 Subject: [PATCH 1/2] chore: remove code duplication --- .../public/empty-scenes/common/generate_all.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/browser-interface/public/empty-scenes/common/generate_all.js b/browser-interface/public/empty-scenes/common/generate_all.js index 40b315546d..1ddab4e973 100644 --- a/browser-interface/public/empty-scenes/common/generate_all.js +++ b/browser-interface/public/empty-scenes/common/generate_all.js @@ -36,16 +36,18 @@ for (let dir of dirs) { } } } + let sourceFile = path.join(__dirname, dir, 'bin/game.js') + let targetFile = path.join(__dirname, 'contents', dir + '.js') if ( fs - .readFileSync(path.join(__dirname, dir, 'bin/game.js')) + .readFileSync(sourceFile) .toString() .startsWith('dcl.subscribe') ) { - fs.copyFileSync(path.join(__dirname, dir, 'bin/game.js'), path.join(__dirname, 'contents', dir + '.js')) + fs.copyFileSync(sourceFile, targetFile) } else { fs.writeFileSync( - path.join(__dirname, 'contents', dir + '.js'), + targetFile, ` dcl.subscribe('sceneStart') @@ -91,7 +93,7 @@ var engine = { dcl.setParent(entity.id, "0") } } -}\n` + fs.readFileSync(path.join(__dirname, dir, 'bin/game.js')).toString() +}\n` + fs.readFileSync(sourceFile).toString() ) } data[dir] = sceneMappings From 2864ea0d646d4f038379e1a630be282bb60d1bcd Mon Sep 17 00:00:00 2001 From: Protean Productions Date: Wed, 17 Apr 2024 05:24:21 +0200 Subject: [PATCH 2/2] fix: correct location of empty-scenes source files --- browser-interface/public/empty-scenes/common/generate_all.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/browser-interface/public/empty-scenes/common/generate_all.js b/browser-interface/public/empty-scenes/common/generate_all.js index 1ddab4e973..6dc9c6734b 100644 --- a/browser-interface/public/empty-scenes/common/generate_all.js +++ b/browser-interface/public/empty-scenes/common/generate_all.js @@ -36,7 +36,7 @@ for (let dir of dirs) { } } } - let sourceFile = path.join(__dirname, dir, 'bin/game.js') + let sourceFile = path.join(__dirname, dir, 'src/game.ts') let targetFile = path.join(__dirname, 'contents', dir + '.js') if ( fs