« get me outta code hell

cli-playground.js « js « src - 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
blob: c5829c253722973e1d569af210b71ae78a95e050 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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));