Initial commit of 001code-html Scratch frontend project.
Includes scratch-gui, scratch-vm, scratch-blocks, scratch-render, scratch-l10n, and deployment config. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
21
scratch-vm/test/fixtures/readProjectFile.js
vendored
Normal file
21
scratch-vm/test/fixtures/readProjectFile.js
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
const AdmZip = require('adm-zip');
|
||||
const fs = require('fs');
|
||||
|
||||
module.exports = {
|
||||
readFileToBuffer: function (path) {
|
||||
return Buffer.from(fs.readFileSync(path));
|
||||
},
|
||||
extractProjectJson: function (path) {
|
||||
const zip = new AdmZip(path);
|
||||
const projectEntry = zip.getEntries().find(item => item.entryName.match(/project\.json/));
|
||||
if (projectEntry) {
|
||||
return JSON.parse(zip.readAsText(projectEntry.entryName, 'utf8'));
|
||||
}
|
||||
return null;
|
||||
},
|
||||
extractAsset: function (path, assetFileName) {
|
||||
const zip = new AdmZip(path);
|
||||
const assetEntry = zip.getEntries().find(item => item.entryName.match(assetFileName));
|
||||
return assetEntry.getData();
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user