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

upPkg new structure change crashing the Tester #49

Open
biancode opened this issue Mar 27, 2021 · 3 comments
Open

upPkg new structure change crashing the Tester #49

biancode opened this issue Mar 27, 2021 · 3 comments

Comments

@biancode
Copy link

upPkg.packageJson.name changed to upPkg.pkg.name

old:

    const upPkg = readPkgUp.sync();
    // case 1: we're in NR itself
    if (upPkg.packageJson.name === 'node-red') {

new:

    const upPkg = readPkgUp.sync();
    // case 1: we're in NR itself
    if (upPkg.pkg.name === 'node-red') {
@knolleary
Copy link
Member

knolleary commented Mar 27, 2021

The latest version of read-pkg-up is 7.0.1, which is the version this module uses, returns packageJson, not pkg.

I seem to remember the module did use to return pkg - but that changed a while ago.

Checking the release history, [email protected] and earlier would return pkg. In v6.0 they changed that to package, before changing it again to packageJson with the 7.0 release.

https://github.com/sindresorhus/read-pkg-up/releases

@biancode
Copy link
Author

biancode commented Mar 28, 2021

That is correct. Hm. The installed helper has 7.0.1 and that has a dependency to 5.2.0. The helper got the packages installed in its own node_modules, but if I use jest for testing it gets the old version by require() from an older package version, which is installed in the main node_modules from another package in that project that I tried to test. Interesting. It was a very fresh installation. I'll try to refresh the project to test it again.

@biancode
Copy link
Author

maybe it is a Jest problem - very fresh install via npm after cache verify etc. - same problem

  ● Test suite failed to run

    TypeError: Cannot read property 'name' of undefined

      19 | var serverCmdNodes = [injectNode, functionNode, serverCmdNode]
      20 |
    > 21 | var helper = require('node-red-node-test-helper')
         |              ^
      22 | helper.init(require.resolve('node-red'))

      at findRuntimePath (node_modules/node-red-node-test-helper/index.js:40:27)
      at NodeTestHelper.init (node_modules/node-red-node-test-helper/index.js:146:38)
      at new NodeTestHelper (node_modules/node-red-node-test-helper/index.js:84:14)
      at Object.<anonymous> (node_modules/node-red-node-test-helper/index.js:352:18)
    const upPkg = readPkgUp.sync();
    // case 1: we're in NR itself
    if (upPkg.packageJson|(Cursor is here).name === 'node-red') {

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

No branches or pull requests

2 participants