mirror of
https://github.com/scratchfoundation/scratch-desktop.git
synced 2024-12-22 21:52:31 -05: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/",
|
||||
"compile": "rimraf ./dist/ && electron-webpack --bail --display-error-details --env.minify=false",
|
||||
"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",
|
||||
"lint": "eslint --cache --color --ext .jsx,.js ."
|
||||
},
|
||||
|
|
|
@ -16,7 +16,7 @@ const describe = function (object) {
|
|||
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 => {
|
||||
let md5Count = 0;
|
||||
if (item.md5) {
|
||||
|
@ -37,10 +37,10 @@ const collectSimple = function (library, debugLabel = 'Item', dest = new Set())
|
|||
return dest;
|
||||
};
|
||||
|
||||
const collectAssets = function (dest = new Set()) {
|
||||
collectSimple(libraries.backdrops, 'Backdrop', dest);
|
||||
collectSimple(libraries.costumes, 'Costume', dest);
|
||||
collectSimple(libraries.sounds, 'Sound', dest);
|
||||
const collectAssets = function (dest) {
|
||||
collectSimple(libraries.backdrops, dest, 'Backdrop');
|
||||
collectSimple(libraries.costumes, dest, 'Costume');
|
||||
collectSimple(libraries.sounds, dest, 'Sound');
|
||||
libraries.sprites.forEach(sprite => {
|
||||
if (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)}`);
|
||||
}
|
||||
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) {
|
||||
collectSimple(sprite.json.sounds, `Sound for sprite ${sprite.name}`);
|
||||
collectSimple(sprite.json.sounds, dest, `Sound for sprite ${sprite.name}`);
|
||||
}
|
||||
});
|
||||
return dest;
|
||||
|
@ -88,7 +88,7 @@ const fetchAsset = function (md5, callback) {
|
|||
};
|
||||
|
||||
const fetchAllAssets = function () {
|
||||
const allAssets = collectAssets();
|
||||
const allAssets = collectAssets(new Set());
|
||||
console.log(`Total library assets: ${allAssets.size}`);
|
||||
|
||||
async.forEachLimit(allAssets, NUM_SIMULTANEOUS_DOWNLOADS, fetchAsset, err => {
|
||||
|
|
Loading…
Reference in a new issue