-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Commander Package does not work with Bun. #1369
Comments
Confirmed on Ubuntu in virtual machine: |
This should be resolved once we support |
import { program } from 'commander';
program.option('--first').option('-s, --separator <char>');
program.parse();
const options = program.opts();
const limit = options.first ? 1 : undefined;
console.log(program.args[0].split(options.separator, limit)); |
@Electroid here you go! 2 | program.option("--first").option("-s, --separator <char>");
3 | program.parse();
3 | const options = program.opts();
4 | const limit = options.first ? 1 : undefined;
5 |
6 | console.log(program.args[0].split(options.separator, limit));
^
TypeError: undefined is not an object (evaluating 'program.args[0].split')
at /tmp/bun-vHJi59/index.js:9:12 Codeimport { program } from 'commander';
program.option('--first').option('-s, --separator <char>');
program.parse();
const options = program.opts();
const limit = options.first ? 1 : undefined;
console.log(program.args[0].split(options.separator, limit)); Ran using the latest build of Bun, an all-in-one JavaScript runtime. |
const { program } = require('commander');
program
.option('--first')
.option('-s, --separator <char>');
program.parse();
const options = program.opts();
console.log("Options:", options);
console.log("Program:", program); |
@Electroid here you go! CommanderError: [Function: CommanderError],
Help: [Function: Help],
InvalidArgumentError: [Function: InvalidArgumentError],
InvalidOptionArgumentError: [Function: InvalidArgumentError],
Option: [Function: Option],
[Symbol(CommonJSTransformed)]: true,
copyInheritedSettings: [Function: copyInheritedSettings],
command: [Function: command],
createCommand: [Function: createCommand],
createHelp: [Function: createHelp],
configureHelp: [Function: configureHelp],
configureOutput: [Function: configureOutput],
showHelpAfterError: [Function: showHelpAfterError],
showSuggestionAfterError: [Function: showSuggestionAfterError],
addCommand: [Function: addCommand],
createArgument: [Function: createArgument],
argument: [Function: argument],
arguments: [Function: arguments],
addArgument: [Function: addArgument],
addHelpCommand: [Function: addHelpCommand],
_hasImplicitHelpCommand: [Function: _hasImplicitHelpCommand],
hook: [Function: hook],
exitOverride: [Function: exitOverride],
_exit: [Function: _exit],
action: [Function: action],
createOption: [Function: createOption],
addOption: [Function: addOption],
_optionEx: [Function: _optionEx],
option: [Function: option],
requiredOption: [Function: requiredOption],
combineFlagAndOptionalValue: [Function: combineFlagAndOptionalValue],
allowUnknownOption: [Function: allowUnknownOption],
allowExcessArguments: [Function: allowExcessArguments],
enablePositionalOptions: [Function: enablePositionalOptions],
passThroughOptions: [Function: passThroughOptions],
storeOptionsAsProperties: [Function: storeOptionsAsProperties],
getOptionValue: [Function: getOptionValue],
setOptionValue: [Function: setOptionValue],
setOptionValueWithSource: [Function: setOptionValueWithSource],
getOptionValueSource: [Function: getOptionValueSource],
_prepareUserArgs: [Function: _prepareUserArgs],
parse: [Function: parse],
parseAsync: [Function: parseAsync],
_executeSubCommand: [Function: _executeSubCommand],
_dispatchSubcommand: [Function: _dispatchSubcommand],
_checkNumberOfArguments: [Function: _checkNumberOfArguments],
_processArguments: [Function: _processArguments],
_chainOrCall: [Function: _chainOrCall],
_chainOrCallHooks: [Function: _chainOrCallHooks],
_chainOrCallSubCommandHook: [Function: _chainOrCallSubCommandHook],
_parseCommand: [Function: _parseCommand],
_findCommand: [Function: _findCommand],
_findOption: [Function: _findOption],
_checkForMissingMandatoryOptions: [Function: _checkForMissingMandatoryOptions],
_checkForConflictingLocalOptions: [Function: _checkForConflictingLocalOptions],
_checkForConflictingOptions: [Function: _checkForConflictingOptions],
parseOptions: [Function: parseOptions],
opts: [Function: opts],
optsWithGlobals: [Function: optsWithGlobals],
error: [Function: error],
_parseOptionsEnv: [Function: _parseOptionsEnv],
_parseOptionsImplied: [Function: _parseOptionsImplied],
missingArgument: [Function: missingArgument],
optionMissingArgument: [Function: optionMissingArgument],
missingMandatoryOptionValue: [Function: missingMandatoryOptionValue],
_conflictingOption: [Function: _conflictingOption],
unknownOption: [Function: unknownOption],
_excessArguments: [Function: _excessArguments],
unknownCommand: [Function: unknownCommand],
version: [Function: version],
description: [Function: description],
summary: [Function: summary],
alias: [Function: alias],
aliases: [Function: aliases],
usage: [Function: usage],
nameFromFilename: [Function: nameFromFilename],
executableDir: [Function: executableDir],
helpInformation: [Function: helpInformation],
_getHelpContext: [Function: _getHelpContext],
outputHelp: [Function: outputHelp],
helpOption: [Function: helpOption],
help: [Function: help],
addHelpText: [Function: addHelpText],
addListener: [Function: addListener],
on: [Function: on],
once: [Function: once],
prepend: [Function: prepend],
prependOnce: [Function: prependOnce],
removeListener: [Function: removeListener],
off: [Function: off],
removeAllListeners: [Function: removeAllListeners],
emit: [Function: emit],
eventNames: [Function: eventNames],
listenerCount: [Function: listenerCount],
listeners: [Function: listeners],
rawListeners: [Function: rawListeners],
setMaxListeners: [Function: setMaxListeners],
getMaxListeners: [Function: getMaxListeners]
} Codeconst { program } = require('commander');
program
.option('--first')
.option('-s, --separator <char>');
program.parse();
const options = program.opts();
console.log("Options:", options);
console.log("Program:", program); Ran using the latest build of Bun, an all-in-one JavaScript runtime. |
It looks like If you're still having issue, please feel free to open another issue. |
@Electroid here you go! 1 | commander;
Refe
ReferenceError: Can't find variable: commander
at /tmp/bun-IABuhM/index.tsx:1:0 Codecommander Ran using the latest build of Bun, an all-in-one JavaScript runtime. |
What version of Bun is running?
0.2.1 (canary)
What platform is your computer?
Darwin 21.6.0 Darwin Kernel Version 21.6.0: Sat Jun 18 17:07:25 PDT 2022; root:xnu-8020.140.41~1/RELEASE_X86_64 x86_64 i386
What steps can reproduce the bug?
bun init
bun add commander
index.ts
This example has been change to the ESM
import
syntax. I get the same result with both.bun index.ts
How often does it reproduce? Is there a required condition?
Every time. There seems to be no required condition.
What is the expected behavior?
The program executes without error.
What do you see instead?
Additional information
No response
The text was updated successfully, but these errors were encountered: