Last active
April 8, 2022 03:28
-
-
Save DavidBuchanan314/be42ae5e5e508dc1902f6f6844f80a59 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// edit this path according to your needs! | |
var projFile = "/Users/david/Sync/programming/python/boiga/test.sb3"; | |
var fs = require("fs"); | |
var vm = document.querySelector("#app")._reactRootContainer.current.child.child.child.stateNode.store.getState().scratchGui.vm; | |
var loading = false; | |
var watcher = fs.watch(projFile, async (event, filename) => { | |
if (!filename || loading) return; | |
var fileContents = await fs.promises.readFile(projFile); | |
if (!fileContents.length) return; | |
console.log("Reloading!"); | |
if (loading) return; | |
loading = true; | |
try { | |
await vm.loadProject(fileContents); | |
} catch (e) { | |
console.log(e); | |
} | |
loading = false; | |
console.log("Done!"); | |
vm.greenFlag(); | |
}); | |
// keep the stage on-screen when the window is narrowed | |
window.onresize = () => {document.body.parentElement.scrollLeft = 999999}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment