Skip to content
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

exception when run in webstorm run tab #9

Closed
Ognian opened this issue Apr 11, 2017 · 5 comments
Closed

exception when run in webstorm run tab #9

Ognian opened this issue Apr 11, 2017 · 5 comments
Assignees
Labels

Comments

@Ognian
Copy link

Ognian commented Apr 11, 2017

When run in web storm terminal all is ok, but when run in "run" tab (by double click on the listed package.json actions) we get:

/usr/local/bin/node /usr/local/lib/node_modules/npm/bin/npm-cli.js run upload-app --scripts-prepend-node-path

> rs232w@0.0.0 upload-app /storage/safe/ogi-it/Projekte/IOT_Gadgets/oios/packages/rs232w
> nodemcu-tool upload app/*

[NodeMCU-Tool] Project based configuration loaded
[NodeMCU-Tool] Connected
[NodeMCU] Version: 2.0.0 | ChipID: 0xea70b | FlashID: 0x1640ef
[NodeMCU-Tool] Uploading "app/init.lua" >> "init.lua"...
/storage/safe/ogi-it/Projekte/IOT_Gadgets/oios/packages/rs232w/node_modules/cli-progress/lib/Bar.js:204
    this.eta.valueBuffer.push(current);
                        ^

TypeError: Cannot read property 'push' of undefined
    at Bar.update (/storage/safe/ogi-it/Projekte/IOT_Gadgets/oios/packages/rs232w/node_modules/cli-progress/lib/Bar.js:204:25)
    at /storage/safe/ogi-it/Projekte/IOT_Gadgets/oios/packages/rs232w/node_modules/nodemcu-tool/bin/nodemcu-tool.js:211:21
    at Function.<anonymous> (/storage/safe/ogi-it/Projekte/IOT_Gadgets/oios/packages/rs232w/node_modules/nodemcu-tool/lib/NodeMCU-Tool.js:227:21)
    at NodeMcuConnector.<anonymous> (/storage/safe/ogi-it/Projekte/IOT_Gadgets/oios/packages/rs232w/node_modules/nodemcu-tool/lib/NodeMcuConnector.js:236:24)
    at ScriptableSerialTerminal.<anonymous> (/storage/safe/ogi-it/Projekte/IOT_Gadgets/oios/packages/rs232w/node_modules/nodemcu-tool/lib/ScriptableSerialTerminal.js:122:17)
    at ScriptableSerialTerminal.<anonymous> (/storage/safe/ogi-it/Projekte/IOT_Gadgets/oios/packages/rs232w/node_modules/nodemcu-tool/lib/ScriptableSerialTerminal.js:73:15)
    at emitOne (events.js:96:13)
    at SerialPort.emit (events.js:189:7)
    at SerialPort.<anonymous> (/storage/safe/ogi-it/Projekte/IOT_Gadgets/oios/packages/rs232w/node_modules/serialport/lib/parsers.js:57:19)
    at SerialPort._emitData (/storage/safe/ogi-it/Projekte/IOT_Gadgets/oios/packages/rs232w/node_modules/serialport/lib/serialport.js:313:18)

npm ERR! Darwin 16.5.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/bin/npm-cli.js" "run" "upload-app" "--scripts-prepend-node-path"
npm ERR! node v7.6.0
npm ERR! npm  v4.1.2
npm ERR! code ELIFECYCLE
npm ERR! rs232w@0.0.0 upload-app: `nodemcu-tool upload app/*`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the rs232w@0.0.0 upload-app script 'nodemcu-tool upload app/*'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the rs232w package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     nodemcu-tool upload app/*
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs rs232w
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls rs232w
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /storage/safe/ogi-it/Projekte/IOT_Gadgets/oios/packages/rs232w/npm-debug.log

Process finished with exit code 1

A workaround is to change the code to:

Bar.prototype.update = function(current){
    // update value
    this.value = current;

    if(this.eta.valueBuffer && this.eta.timeBuffer) {

        this.eta.valueBuffer.push(current);
        this.eta.timeBuffer.push(Date.now());

        // throttle the update or force update ?
        if (this.lastRedraw + this.throttleTime < Date.now()) {
            this.calculateETA();
            this.render();
        }
        if (this.value >= this.getTotal() && this.stopOnComplete) {
            this.stop();
        }
    }
};

But maybe you have a better idea ...

Ognian

@AndiDittrich
Copy link
Member

Dear Ognian,

thanks for your report!

it seems that the WebStorm "run" command calls NodeMCU-Tool the wrong way.... on line 4 of your output the upload action is called with a glob pattern nodemcu-tool upload app/* - this is currently not supported by NodeMCU Tool...

the error of cli-progress is caused because the update method is called before start .. this should be fixed as well

best regards, Andi

@Ognian
Copy link
Author

Ognian commented Apr 12, 2017

Dear Andi,
Webstorm is not to be blamed for calling nodemcu-tool with app/* , its me... Why should this be bad?
Actually I need that and when called in the terminal it works. The difference between terminal and web storm run mode is that istty is false in run mode, thats when the error occurs. You write that cli-progress should be fixed, but I do not see a new version? I'm using nodemcu-tool 2.0.4 which uses cli-progress 1.2.0 although cli progress is already on 1.3.0... Is this the problem?
Thanks Ognian

@AndiDittrich
Copy link
Member

now i understand your issue and of course, cli-progress needs a fix

but in general, wildcard/glob patterns are not implmented in NodeMCU-Tool - calling the tool with app/* will only work under some circumstances... (commander.js will exapand the expression in modern versions)

@AndiDittrich AndiDittrich added bug and removed question labels Apr 12, 2017
@AndiDittrich AndiDittrich self-assigned this Apr 12, 2017
@AndiDittrich
Copy link
Member

i've released cli-progress v1.3.1 including a backward-compatible fix for use in non-tty environments. it should work with NodeMCU-Tool :)

I would appreciate your feedback.

best regards, Andi

@Ognian
Copy link
Author

Ognian commented Apr 13, 2017

This looks good!
I have still a problems with 2 commands of nodemcu-tool when run in non tty mode:

  • mkfs
  • terminal
    the common thing is that they both require an input, and both do not terminate although the function is fulfilled... but i'll open a new issue for that in nodemcu-tool
    Thanks
    Ognian

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants