Skip to content

Commit

Permalink
option log added
Browse files Browse the repository at this point in the history
  • Loading branch information
Сергей Краснов committed Jun 20, 2023
1 parent 7e47c09 commit c45210e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/bright-donkeys-own.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@releaseband/vite-plugin-meta": patch
---

option log
8 changes: 5 additions & 3 deletions src/MetaPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ export default class MetaPlugin {
selectFilesLog: option.selectFilesLog ?? false,
filesHashLog: option.filesHashLog ?? false,
converLog: option.converLog ?? false,
optionLog: option.optionLog ?? false,
};
if (option.optionLog) console.log(this.option);
}

public selectFiles(publicDir: string): void {
Expand All @@ -76,7 +78,7 @@ export default class MetaPlugin {
if (this.option.selectFilesLog) console.log(this.imagesFiles, this.soundsFiles);
}

public async loadHashs(): Promise<void> {
private async loadHashs(): Promise<void> {
checkDir(this.option.storageDir);
const hashConfig = await readConfig(path.join(this.option.storageDir, this.option.hashConfigName));
if (hashConfig) this.filesHash = hashConfig as Record<string, string>;
Expand All @@ -95,7 +97,7 @@ export default class MetaPlugin {
await Promise.all(jobs);
}

public async imagesConversionProcess(): Promise<void> {
private async imagesConversionProcess(): Promise<void> {
const jobs = this.imagesFiles.map(async (imagePath) => {
try {
const fileHash = await makeHash(imagePath);
Expand All @@ -111,7 +113,7 @@ export default class MetaPlugin {
await Promise.all(jobs);
}

public async soundsConversionProcess(): Promise<void> {
private async soundsConversionProcess(): Promise<void> {
const jobs = this.soundsFiles.map(async (soundPath) => {
try {
const fileHash = await makeHash(soundPath);
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ export type MetaPluginOption = {
readonly selectFilesLog?: boolean;
readonly filesHashLog?: boolean;
readonly converLog?: boolean;
readonly optionLog?: boolean;
};
2 changes: 2 additions & 0 deletions src/updateHash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const enum Flags {
selectFilesLog = '--selectFilesLog',
filesHashLog = '--filesHashLog',
converLog = '--converLog',
optionLog = '--optionLog',
}

export const getParameter = (key: string): string | null => {
Expand All @@ -28,6 +29,7 @@ const plugin = new MetaPlugin({
selectFilesLog: checkParameter(Flags.selectFilesLog),
filesHashLog: checkParameter(Flags.filesHashLog),
converLog: checkParameter(Flags.converLog),
optionLog: checkParameter(Flags.optionLog),
});

const publicDir = getParameter(Flags.publicDir) ?? Names.publicDir;
Expand Down

0 comments on commit c45210e

Please sign in to comment.