Skip to content

Commit 4750456

Browse files
committed
[lib] feat(AudioFileConverter): support force option
1 parent d603638 commit 4750456

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

packages/music-library-tools-lib/src/audio-file-converter/audioFileConverter.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ export default class AudioFileConverter {
7373
const {
7474
bitrate = DEFAULT_MP3_BITRATE,
7575
codec,
76-
// TODO: implement 'force' option
77-
// force = false,
76+
force = false,
7877
outputDirKind,
7978
sampleRate = DEFAULT_AUDIO_SAMPLE_RATE,
8079
} = options;
@@ -88,8 +87,14 @@ export default class AudioFileConverter {
8887
const outputFilePath = join(outputFolder, outputFileName);
8988

9089
if (existsSync(outputFilePath)) {
91-
log.info(`MP3 file already exists at ${outputFilePath}, skipping conversion`);
92-
return Promise.resolve(outputFilePath);
90+
if (force) {
91+
log.info(
92+
`MP3 file already exists at ${outputFilePath}, but force flag is set, re-converting...`,
93+
);
94+
} else {
95+
log.info(`MP3 file already exists at ${outputFilePath}, skipping conversion.`);
96+
return Promise.resolve(outputFilePath);
97+
}
9398
}
9499

95100
return new Promise<string>((resolve, reject) => {

0 commit comments

Comments
 (0)