Skip to content

Commit

Permalink
types (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
GoodBoyDigital authored Feb 5, 2025
1 parent 89c8a54 commit 39e511b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
7 changes: 6 additions & 1 deletion packages/assetpack/src/core/Asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,12 @@ export class Asset
Logger.warn('[AssetPack] folders should not have hashes. Contact the developer of the AssetPack');
}

this._hash ??= getHash(this.buffer);
try
{
this._hash ??= getHash(this.buffer);
}
catch (error)
{ /* empty */ }

return this._hash;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/assetpack/src/spine/spineAtlasCacheBuster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function spineAtlasCacheBuster(): AssetPipe
// as we do this, the hash of the atlas file will change, so we need to update the path
// and also remove the original file.

const originalHash = atlasAsset.hash;
const originalHash = atlasAsset.hash!;
const originalPath = atlasAsset.path;

const atlasView = new AtlasView(atlasAsset.buffer);
Expand All @@ -70,7 +70,7 @@ export function spineAtlasCacheBuster(): AssetPipe

atlasAsset.buffer = atlasView.buffer;

atlasAsset.path = atlasAsset.path.replace(originalHash, atlasAsset.hash);
atlasAsset.path = atlasAsset.path.replace(originalHash, atlasAsset.hash!);

fs.removeSync(originalPath);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function texturePackerCacheBuster(): AssetPipe<any, 'tps'>
// as we do this, the hash of the atlas file will change, so we need to update the path
// and also remove the original file.
const jsonAsset = jsonAssets[i];
const originalHash = jsonAsset.hash;
const originalHash = jsonAsset.hash!;
const originalPath = jsonAsset.path;

const json = JSON.parse(jsonAsset.buffer.toString());
Expand All @@ -79,7 +79,7 @@ export function texturePackerCacheBuster(): AssetPipe<any, 'tps'>
}

jsonAsset.buffer = Buffer.from(JSON.stringify(json));
jsonAsset.path = jsonAsset.path.replace(originalHash, jsonAsset.hash);
jsonAsset.path = jsonAsset.path.replace(originalHash, jsonAsset.hash!);
fs.removeSync(originalPath);

// rewrite..
Expand Down

0 comments on commit 39e511b

Please sign in to comment.