mirror of
https://github.com/scratchfoundation/scratch-desktop.git
synced 2025-06-05 01:24:21 -04:00
fix scripts/fetchMediaLibraryAssets.js missing some sprite assets
Assets which are referenced by a sprite but not referenced by the sound, costume, or backdrop libraries were being missed by previous versions. I also removed the default parameter to several methods in order to reduce the likelihood of similar mistakes in the future.
This commit is contained in:
parent
7b13482bc6
commit
91e16c2ab5
2 changed files with 9 additions and 9 deletions
|
@ -11,7 +11,7 @@
|
||||||
"clean": "rimraf ./dist/ ./static/assets/",
|
"clean": "rimraf ./dist/ ./static/assets/",
|
||||||
"compile": "rimraf ./dist/ && electron-webpack --bail --display-error-details --env.minify=false",
|
"compile": "rimraf ./dist/ && electron-webpack --bail --display-error-details --env.minify=false",
|
||||||
"fetch": "rimraf ./static/assets/ && mkdirp ./static/assets/ && node ./scripts/fetchMediaLibraryAssets.js",
|
"fetch": "rimraf ./static/assets/ && mkdirp ./static/assets/ && node ./scripts/fetchMediaLibraryAssets.js",
|
||||||
"dist": "npm run fetch && npm run compile -p && electron-builder",
|
"dist": "npm run build-gui && npm run fetch && npm run compile -p && electron-builder",
|
||||||
"dist:dir": "npm run dist -- --dir -c.compression=store -c.mac.identity=null",
|
"dist:dir": "npm run dist -- --dir -c.compression=store -c.mac.identity=null",
|
||||||
"lint": "eslint --cache --color --ext .jsx,.js ."
|
"lint": "eslint --cache --color --ext .jsx,.js ."
|
||||||
},
|
},
|
||||||
|
|
|
@ -16,7 +16,7 @@ const describe = function (object) {
|
||||||
return util.inspect(object, false, Infinity, true);
|
return util.inspect(object, false, Infinity, true);
|
||||||
};
|
};
|
||||||
|
|
||||||
const collectSimple = function (library, debugLabel = 'Item', dest = new Set()) {
|
const collectSimple = function (library, dest, debugLabel = 'Item') {
|
||||||
library.forEach(item => {
|
library.forEach(item => {
|
||||||
let md5Count = 0;
|
let md5Count = 0;
|
||||||
if (item.md5) {
|
if (item.md5) {
|
||||||
|
@ -37,10 +37,10 @@ const collectSimple = function (library, debugLabel = 'Item', dest = new Set())
|
||||||
return dest;
|
return dest;
|
||||||
};
|
};
|
||||||
|
|
||||||
const collectAssets = function (dest = new Set()) {
|
const collectAssets = function (dest) {
|
||||||
collectSimple(libraries.backdrops, 'Backdrop', dest);
|
collectSimple(libraries.backdrops, dest, 'Backdrop');
|
||||||
collectSimple(libraries.costumes, 'Costume', dest);
|
collectSimple(libraries.costumes, dest, 'Costume');
|
||||||
collectSimple(libraries.sounds, 'Sound', dest);
|
collectSimple(libraries.sounds, dest, 'Sound');
|
||||||
libraries.sprites.forEach(sprite => {
|
libraries.sprites.forEach(sprite => {
|
||||||
if (sprite.md5) {
|
if (sprite.md5) {
|
||||||
dest.add(sprite.md5);
|
dest.add(sprite.md5);
|
||||||
|
@ -48,10 +48,10 @@ const collectAssets = function (dest = new Set()) {
|
||||||
console.warn(`Sprite has no MD5 property:\n${describe(sprite)}`);
|
console.warn(`Sprite has no MD5 property:\n${describe(sprite)}`);
|
||||||
}
|
}
|
||||||
if (sprite.json.costumes) {
|
if (sprite.json.costumes) {
|
||||||
collectSimple(sprite.json.costumes, `Costume for sprite ${sprite.name}`);
|
collectSimple(sprite.json.costumes, dest, `Costume for sprite ${sprite.name}`);
|
||||||
}
|
}
|
||||||
if (sprite.json.sounds) {
|
if (sprite.json.sounds) {
|
||||||
collectSimple(sprite.json.sounds, `Sound for sprite ${sprite.name}`);
|
collectSimple(sprite.json.sounds, dest, `Sound for sprite ${sprite.name}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return dest;
|
return dest;
|
||||||
|
@ -88,7 +88,7 @@ const fetchAsset = function (md5, callback) {
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchAllAssets = function () {
|
const fetchAllAssets = function () {
|
||||||
const allAssets = collectAssets();
|
const allAssets = collectAssets(new Set());
|
||||||
console.log(`Total library assets: ${allAssets.size}`);
|
console.log(`Total library assets: ${allAssets.size}`);
|
||||||
|
|
||||||
async.forEachLimit(allAssets, NUM_SIMULTANEOUS_DOWNLOADS, fetchAsset, err => {
|
async.forEachLimit(allAssets, NUM_SIMULTANEOUS_DOWNLOADS, fetchAsset, err => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue