Skip to content

Commit

Permalink
catch and notify?
Browse files Browse the repository at this point in the history
  • Loading branch information
RedMan13 committed Dec 6, 2024
1 parent f2d549e commit eb1e9b6
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions src/virtual-machine.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,20 +453,24 @@ class VirtualMachine extends EventEmitter {
}

const validationPromise = new Promise(async (resolve, reject) => {
const arr = new Uint8Array(input);
const tag = [...arr.slice(0, 7)]
.map(char => String.fromCharCode(char))
.join('');
console.log(tag);
if (tag === 'Scratch') return reject();
if (typeof input === 'string') {
input.projectVersion = !input.meta ? 2 : 3;
return resolve([JSON.parse(input), null]);
try {
const arr = new Uint8Array(input);
const tag = [...arr.slice(0, 7)]
.map(char => String.fromCharCode(char))
.join('');
console.log(tag);
if (tag === 'Scratch') return reject();
if (typeof input === 'string') {
input.projectVersion = !input.meta ? 2 : 3;
return resolve([JSON.parse(input), null]);
}
const zip = await JSZip.loadAsync(input);
const json = JSON.parse(await zip.file('project.json').async('string'));
json.projectVersion = !json.meta ? 2 : 3;
return resolve([json, zip]);
} catch (err) {
reject(err.toString());
}
const zip = await JSZip.loadAsync(input);
const json = JSON.parse(await zip.file('project.json').async('string'));
json.projectVersion = !json.meta ? 2 : 3;
return resolve([json, zip]);
/*
const validate = require('scratch-parser');
// The second argument of false below indicates to the validator that the
Expand Down

0 comments on commit eb1e9b6

Please sign in to comment.