dpa99c / cordova-check-plugins

A CLI tool to check for / manage plugin updates in Cordova/Phonegap projects.
217 stars 25 forks source link

TypeError: Cannot read property '1' of null #2

Closed palafoxernesto closed 8 years ago

palafoxernesto commented 8 years ago

Hi, i've just installed the plugin and when running:

cordova-check-plugins I got this error:

/cordova-check-plugins/index.js:125
        user = parts[1],
                    ^
TypeError: Cannot read property '1' of null

I am missing anything? Thank you

dpa99c commented 8 years ago

This error is related to a plugin whose source is detected as Github. Could do with some better error handling here, though. Will add that to my TODO list.

The module scans the plugins listed in plugins/fetch.json and on detecting the source.type is "git", the module attempts to parse the github URL in source.url.

This error is raised because the regex didn't match. Can you post the contents of your plugins/fetch.json?

dpa99c commented 8 years ago

Just published an update (1.0.6) which should have better error handlign

dpa99c commented 8 years ago

Should be fixed by v1.0.6

riegeljonez commented 8 years ago

Hi @dpa99c – i justed wanted to drop a note that I still get this failure message in v1.0.7

This is my fetch.json: { "cordova-plugin-device": { "source": { "type": "registry", "id": "cordova-plugin-device" }, "is_top_level": true, "variables": {} }, "cordova-plugin-console": { "source": { "type": "registry", "id": "cordova-plugin-console" }, "is_top_level": true, "variables": {} }, "cordova-plugin-whitelist": { "source": { "type": "registry", "id": "cordova-plugin-whitelist" }, "is_top_level": true, "variables": {} }, "cordova-plugin-splashscreen": { "source": { "type": "registry", "id": "cordova-plugin-splashscreen" }, "is_top_level": true, "variables": {} }, "cordova-plugin-statusbar": { "source": { "type": "registry", "id": "cordova-plugin-statusbar" }, "is_top_level": true, "variables": {} }, "ionic-plugin-keyboard": { "source": { "type": "registry", "id": "ionic-plugin-keyboard" }, "is_top_level": true, "variables": {} }, "cordova-plugin-geolocation": { "source": { "type": "registry", "id": "cordova-plugin-geolocation" }, "is_top_level": true, "variables": {} }, "cordova-plugin-network-information": { "source": { "type": "registry", "id": "cordova-plugin-network-information" }, "is_top_level": true, "variables": {} }, "cordova-plugin-geofence": { "source": { "type": "registry", "id": "cordova-plugin-geofence" }, "is_top_level": true, "variables": {} }, "es6-promise-plugin": { "source": { "type": "registry", "id": "es6-promise-plugin" }, "is_top_level": false, "variables": {} }, "cordova-plugin-file-transfer": { "source": { "type": "registry", "id": "cordova-plugin-file-transfer" }, "is_top_level": true, "variables": {} }, "cordova-plugin-file": { "source": { "type": "registry", "id": "cordova-plugin-file@~4.1.0" }, "is_top_level": true, "variables": {} }, "cordova-plugin-inappbrowser": { "source": { "type": "registry", "id": "cordova-plugin-inappbrowser@~1.2.0" }, "is_top_level": true, "variables": {} } }

dpa99c commented 8 years ago

I will have a look at it later

rainchen commented 8 years ago

same issue

↪  cordova-check-plugins                                                                                                                              Fri Mar  4 15:52:44 CST 2016
Running cordova-check-plugins...
Checking remote versions... \/Users/rain/.nvm/versions/v0.12.7/lib/node_modules/cordova-check-plugins/index.js:115
            version = versions.pop().match(/@([\d.]+)/)[1];
                                                       ^
TypeError: Cannot read property '1' of null
    at /Users/rain/.nvm/versions/v0.12.7/lib/node_modules/cordova-check-plugins/index.js:115:56
    at ChildProcess.exithandler (child_process.js:742:7)
    at ChildProcess.emit (events.js:110:17)
    at maybeClose (child_process.js:1015:16)
    at Socket.<anonymous> (child_process.js:1183:11)
    at Socket.emit (events.js:107:17)
    at Pipe.close (net.js:485:12)
dpa99c commented 8 years ago

@rainchen Can you please post the contents of your plugins/fetch.json also?

I will compare it with the one from @riegeljonez and see if I can find the cause of this. I suspect the regex for matching versions needs to be smarter...

rainchen commented 8 years ago

@dpa99c here is:

{
    "cordova-plugin-device": {
        "source": {
            "type": "registry",
            "id": "cordova-plugin-device@~1.1.1"
        },
        "is_top_level": true,
        "variables": {}
    },
    "cordova-plugin-console": {
        "source": {
            "type": "registry",
            "id": "cordova-plugin-console@~1.0.2"
        },
        "is_top_level": true,
        "variables": {}
    },
    "cordova-plugin-whitelist": {
        "source": {
            "type": "registry",
            "id": "cordova-plugin-whitelist@~1.2.1"
        },
        "is_top_level": true,
        "variables": {}
    },
    "cordova-plugin-splashscreen": {
        "source": {
            "type": "registry",
            "id": "cordova-plugin-splashscreen@~3.1.0"
        },
        "is_top_level": true,
        "variables": {}
    },
    "cordova-plugin-inappbrowser": {
        "source": {
            "type": "registry",
            "id": "cordova-plugin-inappbrowser@~1.2.0"
        },
        "is_top_level": true,
        "variables": {}
    },
    "cordova-plugin-geolocation": {
        "source": {
            "type": "registry",
            "id": "cordova-plugin-geolocation@~2.1.0"
        },
        "is_top_level": true,
        "variables": {}
    }
}
dpa99c commented 8 years ago

Yep, I can see the problem now. The regex /@([\d.]+)/ is not matching because of ~. It should ignore this and any other special chars preceding version number (e.g. ^). It also needs to be able to match versions containing pre-release tags e.g. @1.2.0-dev. I'll have a look at this tonight.

dpa99c commented 8 years ago

I've just pushed a new version - 1.0.8 - to npm. It should hopefully resolve this issue. Let me know.

dpa99c commented 8 years ago

Reopen if still an issue

rainchen commented 8 years ago

@dpa99c the TypeError error is gone, but the result is weird:

↪  cordova-check-plugins                                                                                                                              Thu Mar 10 11:43:19 CST 2016
Running cordova-check-plugins...
Checking remote versions... |'1.1.1\n\n'
Checking remote versions... /'cordova-plugin-inappbrowser@1.2.0 \'1.2.0\'\ncordova-plugin-inappbrowser@1.2.1 \'1.2.1\'\n\n'
'4.2.0\n\n'
Checking remote versions... \'1.0.2\n\n'
'1.2.1\n\n'
Checking remote versions... /'3.1.0\n\n'
Checking remote versions... /'1.0.8\n\n'
'2.1.0\n\n'

I can open an new issue for this if you wish.

dpa99c commented 8 years ago

@rainchen Oops, left in a line of debug. Removed and pushed as v1.0.10 to npm

rainchen commented 8 years ago

@dpa99c working well now! cool