question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to convert a .sb3 to .html in the command line?

See original GitHub issue

I have a repo with scratch files (sb3) and I’d love to have my pipeline convert them to html and host them via github/gitlab pages.

Can I use this repo to do that? Is there some documentation?

I’m looking for something like

npm convert --to-html file.sb3 --output public/file.html

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
GarboMuffincommented, Oct 14, 2022

Here’s a more complete fixed version with Packager vs packager also fixed

const fs = require('fs')
const path = require('path')
const Packager = require('@turbowarp/packager')

const run = async () => {
  const projectFile = process.argv[2];
  console.log("Project File: "+projectFile);
  const projectData = fs.readFileSync(projectFile);
  const progressCallback = () => {};
  const loadedProject = await Packager.loadProject(projectData, progressCallback);

  const packager = new Packager.Packager();
  packager.project = loadedProject;

  const result = await packager.package();
  fs.writeFileSync(path.join(__dirname, 'demo_output.html'), result.data);
};

run()
  .catch((err) => {
    console.error(err);
    process.exit(1);
  });
1reaction
GarboMuffincommented, Oct 14, 2022

you should do this instead:

  const projectData = fs.readFileSync(projectFile);
  const progressCallback = () => {};
  const loadedProject = await packager.loadProject(projectData, progressCallback);

loadProject has a second argument that’s a function it’ll call with progress information. It’s supposed to be optional but apparently that was broken at some point

Read more comments on GitHub >

github_iconTop Results From Across the Web

Convert sb3 to exe (tutorial) - Discuss Scratch
Copy the project.html file downloaded from the sb3 htmlifier, and paste this file in the folder where you created package.json. Open nw.exe ...
Read more >
Porting Scratch Projects
Open the command line. On Windows, type "Command Prompt" in the search bar in the bottom left and open.
Read more >
RexScratch/sb3tosb2: Converts SB3 files to SB2 files - GitHub
SB3 to SB2 Converter. A simple Python 3 program that converts ... Open the terminal or command prompt and navigate to the directory...
Read more >
How To Convert A Sb3 File To An Exe - ADocLib
... the Scratch how to turn a Scratch project into various executable file formats for command line, an alternative is to use the...
Read more >
Project HTMLifier - SheepTester
Convert a Scratch project to HTML. HTMLify. This packages your Scratch project into a single HTML file that can run on its own...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found