Skip to content

Commit

Permalink
update logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Zyie committed May 9, 2024
1 parent 64123cc commit 517d80c
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/core/Asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export class Asset
{
if (this.isFolder)
{
Logger.warn('[Assetpack] folders should not have buffers!. Contact the developer of Assetpack');
Logger.warn('[AssetPack] folders should not have buffers!. Contact the developer of Assetpack');
}

if (!this._buffer)
Expand All @@ -130,7 +130,7 @@ export class Asset
{
if (this.isFolder)
{
Logger.warn('[Assetpack] folders should not have hashes. Contact the developer of the Assetpack');
Logger.warn('[AssetPack] folders should not have hashes. Contact the developer of the Assetpack');
}

this._hash ??= getHash(this.buffer);
Expand Down
12 changes: 4 additions & 8 deletions src/core/AssetPack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,10 @@ export class AssetPack

const { pipes, cache, cacheLocation } = this.config;

// make a hash..
const cacheName = generateCacheName(this.config);

AssetCache.location = cacheLocation!;
let assetCacheData = null;
let assetCache: AssetCache | null = null;

AssetCache.location = cacheLocation!;

// if there is no cache, lets just go ahead and remove the output folder
// and the cached info folder
if (!cache)
Expand All @@ -65,7 +61,7 @@ export class AssetPack
// create the asset cache, this is used to store the asset graph information
// so if you restart the process, it can pick up where it left off
assetCache = new AssetCache({
cacheName,
cacheName: generateCacheName(this.config),
});

// read the cache data, this will be used to restore the asset graph
Expand All @@ -74,11 +70,11 @@ export class AssetPack

if (assetCacheData)
{
Logger.info('cache found.');
Logger.info('[AssetPack] cache found.');
}
else
{
Logger.warn('cache not found, clearing output folder');
Logger.warn('[AssetPack] cache not found, clearing output folder');

// to be safe - lets nuke the folder as the cache is empty
fs.removeSync(this._outputPath);
Expand Down
2 changes: 1 addition & 1 deletion src/image/compress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export function compress(options: CompressOptions = {}): AssetPipe<CompressOptio
}
catch (error)
{
throw new Error(`[AssetPack] Failed to compress image: ${asset.path} - ${error}`);
throw new Error(`[AssetPack][compress] Failed to compress image: ${asset.path} - ${error}`);
}
},

Expand Down
2 changes: 1 addition & 1 deletion src/image/mipmap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export function mipmap(_options: MipmapOptions = {}): AssetPipe<MipmapOptions>
}
catch (error)
{
throw new Error(`[AssetPack] Failed to mipmap image: ${asset.path} - ${error}`);
throw new Error(`[AssetPack][mipmap] Failed to mipmap image: ${asset.path} - ${error}`);
}

// now create our new assets
Expand Down
2 changes: 1 addition & 1 deletion src/json/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export function json(_options: JsonOptions = {}): AssetPipe
}
catch (e)
{
Logger.warn(`[json] Failed to compress json file: ${asset.path}`);
Logger.warn(`[AssetPack][json] Failed to compress json file: ${asset.path}`);

return [asset];
}
Expand Down
4 changes: 2 additions & 2 deletions src/texture-packer/packer/createTextureData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export async function createTextureData(options: Required<PackTexturesOptions>)

if (!metaData.width || !metaData.height)
{
throw new Error(`[Assetpack][packTextures] Could not get metadata for ${texture.path}`);
throw new Error(`[AssetPack][packTextures] Could not get metadata for ${texture.path}`);
}

const newWidth = Math.ceil(metaData.width * scale);
Expand Down Expand Up @@ -57,7 +57,7 @@ export async function createTextureData(options: Required<PackTexturesOptions>)
let result = await sharpImage.toBuffer({ resolveWithObject: true }).catch((error) =>
{
// eslint-disable-next-line max-len
Logger.warn(`[Assetpack][packTextures] Failed to process texture: ${texture.path} - ${error}, using empty pixel texture instead.`);
Logger.warn(`[AssetPack][packTextures] Failed to process texture: ${texture.path} - ${error}, using empty pixel texture instead.`);

return { data: null, info: null };
});
Expand Down
4 changes: 2 additions & 2 deletions src/texture-packer/texturePacker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function checkForTexturePackerShortcutClashes(
if (clashes.length > 0)
{
// eslint-disable-next-line max-len
Logger.warn(`[Assetpack][texturePacker] Texture Packer Shortcut clash detected for between ${clashes.join(', ')}. This means that 'nameStyle' is set to 'short' and different sprite sheets have frames that share the same name. Please either rename the files or set 'nameStyle' in the texture packer options to 'relative'`);
Logger.warn(`[AssetPack][texturePacker] Texture Packer Shortcut clash detected for between ${clashes.join(', ')}. This means that 'nameStyle' is set to 'short' and different sprite sheets have frames that share the same name. Please either rename the files or set 'nameStyle' in the texture packer options to 'relative'`);
}
}

Expand Down Expand Up @@ -74,7 +74,7 @@ export function texturePacker(_options: TexturePackerOptions = {}): AssetPipe<Te

return {
folder: true,
name: 'texture-packer-pixi',
name: 'texture-packer',
defaultOptions,
test(asset: Asset, options)
{
Expand Down
4 changes: 2 additions & 2 deletions src/texture-packer/texturePackerManifestMod.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fs from 'fs-extra';
import { findAssets, path } from '../core/index.js';
import { findAssets, Logger, path } from '../core/index.js';

import type { Asset, AssetPipe, PluginOptions } from '../core/index.js';

Expand Down Expand Up @@ -56,7 +56,7 @@ export function texturePackerManifestMod(
if (!fs.existsSync(newFileName))
{
// eslint-disable-next-line max-len
console.warn(`[Assetpack] Texture Packer Manifest could not find the manifest: ${newFileName}. Please ensure that the 'pixiManifest' output and the 'texturePackerManifest' output are the same.`);
Logger.warn(`[AssetPack][texture-packer-manifest] Texture Packer Manifest could not find the manifest: ${newFileName}. Please ensure that the 'pixiManifest' output and the 'texturePackerManifest' output are the same.`);

return;
}
Expand Down
2 changes: 1 addition & 1 deletion test/texture-packer/texturePacker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ describe('Texture Packer', () =>
// Check if console.warn was called
expect(mockWarn).toHaveBeenCalled();
// eslint-disable-next-line max-len
expect(mockWarn).toHaveBeenCalledWith(`[Assetpack][texturePacker] Texture Packer Shortcut clash detected for between sprite9.png, sprite8.png, sprite7.png, sprite6.png, sprite5.png, sprite4.png, sprite3.png, sprite2.png, sprite1.png, sprite0.png. This means that 'nameStyle' is set to 'short' and different sprite sheets have frames that share the same name. Please either rename the files or set 'nameStyle' in the texture packer options to 'relative'`); // Adjust this line based on expected message
expect(mockWarn).toHaveBeenCalledWith(`[AssetPack][texturePacker] Texture Packer Shortcut clash detected for between sprite9.png, sprite8.png, sprite7.png, sprite6.png, sprite5.png, sprite4.png, sprite3.png, sprite2.png, sprite1.png, sprite0.png. This means that 'nameStyle' is set to 'short' and different sprite sheets have frames that share the same name. Please either rename the files or set 'nameStyle' in the texture packer options to 'relative'`); // Adjust this line based on expected message

// Restore console.warn
mockWarn.mockRestore();
Expand Down

0 comments on commit 517d80c

Please sign in to comment.