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

Add XDG base directory spec support #294

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Alrefai
Copy link

@Alrefai Alrefai commented Jul 2, 2023

  • fix(test): add NPM_CONFIG_CACHE dir support

The 'should install an npm module transparently' test did not account for the possibility that the NPM_CONFIG_CACHE environment variable might be set. So, it would fail in that case. The fix includes checking the value of NPM_CONFIG_CACHE and using that value if it is set, otherwise defaulting to .npm directory.

Summary of all failing tests
 FAIL  packages/mrm/src/__tests__/index.spec.js (12.65s)
  ● resolveUsingNpx › should install an npm module transparently

    : Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.Error:

      102 | 
      103 | describe('resolveUsingNpx', () => {
    > 104 |     it('should install an npm module transparently', async () => {
          |     ^
      105 |             const result = await resolveUsingNpx('yarnhook');
      106 |             expect(result).toMatch(
      107 |                     /\.npm\/_npx\/\d*\/lib(64)?\/node_modules\/yarnhook\/index\.js$/

      at new Spec (node_modules/jest-jasmine2/build/jasmine/Spec.js:116:22)
      at Suite.<anonymous> (packages/mrm/src/__tests__/index.spec.js:104:2)
      at Object.<anonymous> (packages/mrm/src/__tests__/index.spec.js:103:1)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)

  ● resolveUsingNpx › should throw if npm module is not found on the registry

    expect(received).toMatch(expected)

    Expected pattern: /\.npm\/_npx\/\d*\/lib(64)?\/node_modules\/yarnhook\/index\.js$/
    Received string:  "/Users/mohammed/.cache/npm/_npx/23946/lib/node_modules/yarnhook/index.js"

      104 |     it('should install an npm module transparently', async () => {
      105 |             const result = await resolveUsingNpx('yarnhook');
    > 106 |             expect(result).toMatch(
          |                            ^
      107 |                     /\.npm\/_npx\/\d*\/lib(64)?\/node_modules\/yarnhook\/index\.js$/
      108 |             );
      109 |     });

      at Object.<anonymous> (packages/mrm/src/__tests__/index.spec.js:106:18)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)
  • feat(config): add XDG base directory spec support

This change enables users to organize their config file according to the XDG Base Directory specification.

  • docs(md): add XDG base directory instructions

The 'should install an npm module transparently' test did not account
for the possibility that the `NPM_CONFIG_CACHE` environment variable
might be set. So, it would fail in that case. The fix includes checking
the value of `NPM_CONFIG_CACHE` and using that value if it is set,
otherwise defaulting to `.npm` directory.
This change enables users to organize their config file according to the
XDG Base Directory specification.
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

Successfully merging this pull request may close these issues.

None yet

1 participant