« get me outta code hell

scratchblocks-generator-3 - scratchblocks generator for projects made in 3.0
about summary refs log tree commit diff
path: root/src/js/cli-playground.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/js/cli-playground.js')
-rw-r--r--src/js/cli-playground.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/js/cli-playground.js b/src/js/cli-playground.js
new file mode 100644
index 0000000..c5829c2
--- /dev/null
+++ b/src/js/cli-playground.js
@@ -0,0 +1,21 @@
+'use strict';
+
+// Not actually included in the output bundle.
+
+const { scriptToScratchblocks } = require('./sb3-gen');
+
+async function main() {
+    const fs = require('fs');
+    const path = require('path');
+    const readFile = util.promisify(fs.readFile);
+    const sb3 = process.argv[2];
+    if (!sb3) {
+        console.error('Please pass an sb3 file.');
+        process.exit(1);
+    }
+    const file = await readFile(sb3);
+    const project = await Project.fromSb3(file);
+    console.log(scriptToScratchblocks(project.sprites[1].scripts[0], project.sprites[1]));
+}
+
+main().catch(err => console.error(err));