Skip to content

Commit

Permalink
refactor!: move main into bin
Browse files Browse the repository at this point in the history
BREAKING CHANGE: the main export has been removed since the version was incorrect
  • Loading branch information
joshunrau committed Aug 25, 2024
1 parent be2529f commit fa6144c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 39 deletions.
36 changes: 34 additions & 2 deletions bin/ytdl-mp3.cjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
#!/usr/bin/env node

const { main } = require('../dist/index.cjs');
const { Command } = require('commander');

main();
const { description, name, version } = require('../package.json');
const { Downloader, YtdlMp3Error } = require('../dist/index.cjs');

const program = new Command();
program.name(name);
program.description(description);
program.version(version);
program.allowExcessArguments(false);
program.argument('<url>', 'url of video to download');
program.option('-o --output-dir <path>', 'path to output directory', Downloader.defaultDownloadsDir);
program.option('-n --no-get-tags', 'skip extracting/applying id3 tags');
program.option('-v --verify-tags', 'verify id3 tags fetched from itunes');
program.option('-s --silent-mode', 'skip console output');
program.option('--verbose', 'enable verbose mode');
program.parse();

(async function () {
const options = program.opts();
try {
const downloader = new Downloader(options);
await downloader.downloadSong(program.args[0]);
} catch (err) {
if (err instanceof YtdlMp3Error) {
if (options.verbose) {
console.error(err.cause);
console.error(err.stack);
}
console.error(`ERROR: ${err.message}`);
process.exit(1);
}
throw err;
}
})();
1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export * from './Downloader';
export * from './FormatConverter';
export * from './SongTagsSearch';
export { main } from './main';
export { YtdlMp3Error } from './utils';
36 changes: 0 additions & 36 deletions src/main.ts

This file was deleted.

0 comments on commit fa6144c

Please sign in to comment.