-
Notifications
You must be signed in to change notification settings - Fork 12
Description
Hello @larryrider,
I initially described this problem (+ a fix) in my pull request #130.
Unfortunately, it seems that neither version 1.5.0 nor 1.5.1 really fixed the problem.
Indeed, when internxt list is called:
- when the token has expired token (need to relogin),
- without --id (to use the default root directory),
- with the --non-interactive flag,
- in a non-interactive environment (for example with its standard output piped to another process like cat or grep),
… it crashes like this:
internxt list --non-interactive | grep value
› Error: [REPORTED_ERROR]: No id flag has been provided
› Properties => {
› "command": "list"
› }
› Stack => Error: No id flag has been provided
› at CLIUtils.getValueFromFlag
› (…/dist/utils/cli.utils.js:73:19)
› at List.getFolderUuid
› (…/dist/commands/list.js:79:55)
› at List.run
› (…/dist/commands/list.js:37:37)
› at async List._run
› (…ib/command.js:181:22)
› at async Config.runCommand
› (…ib/config/config.js:456:25)
› at async run (…ib/main.js:96:16)
› at async …/bin/run.js:6:3
For comparison, in the same situation but in a regular terminal, internxt list does not crash (although the error is hard to interpret -- something like "expired token, please relogin" would be better):
internxt list --non-interactive
⚠ Error: Cannot read properties of undefined (reading 'newToken')
Similarly, in the same situation but with a non-expired token, it doesn't crash:
internxt list --non-interactive | grep value
┌────────┬─────────────────────────┬──────────────────────────────────────┐
│ Type │ Name │ Id │
├────────┼─────────────────────────┼──────────────────────────────────────┤
│ … │ … │ … │
This dirty fix is enough to solve the issue (it's similar to what my pull request #130 did):
--- a/node_modules/@internxt/cli/dist/commands/list.js
+++ b/node_modules/@internxt/cli/dist/commands/list.js
@@ -76,6 +76,7 @@ class List extends core_1.Command {
this.exit(1);
};
getFolderUuid = async (folderUuidFlag, nonInteractive) => {
+ if (!folderUuidFlag && nonInteractive) return '';
const folderUuid = await cli_utils_1.CLIUtils.getValueFromFlag({
value: folderUuidFlag,
name: List.flags['id'].name,Could you fix it? If not, would you accept a pull request?