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

feat: support -g, --global install arg #53

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

marvinhagemeister
Copy link
Collaborator

This PR adds support for installing packages globally via jsr i -g <package>. This allows jsr to self update via jsr i -g jsr for example.

Not sure how to write tests for this as the other package managers don't seem to have a way to temporarily overwrite the global install location.

Fixes #46

@ayushkavad
Copy link

ayushkavad commented Jul 15, 2024

@marvinhagemeister I've conducted a series of test cases to validate the global installation feature introduced in this PR:

describe('global install', () => {
  it('jsr i global --npm @std/encoding', async () => {
    await withTempEnv(
      ['i', 'global', '--npm', '@std/encoding'],
      async (dir) => {
        const nodeModules = path.join(dir, 'node_modules', '@std', 'encoding');
        assert.ok(
          await isDirectory(nodeMoules),
          ' node_modules path does not exist',
        );
      },
    );
  });

  it('jsr i global --yarn @std/encoding', async () => {
    await withTempEnv(
      ['i', 'global', '--yarn', '@std/encoding'],
      async (dir) => {
        const nodeModules = path.join(dir, 'node_modules', '@std', 'encoding');
        assert.ok(
          await isDirectory(nodeMoules),
          ' node_modules path does not exist',
        );
      },
    );
  });

  it('jsr i global --pnpm @std/encoding', async () => {
    await withTempEnv(
      ['i', 'global', '--pnpm', '@std/encoding'],
      async (dir) => {
        const nodeModules = path.join(dir, 'node_modules', '@std', 'encoding');
        assert.ok(
          await isDirectory(nodeMoules),
          ' node_modules path does not exist',
        );
      },
    );
  });

  it('jsr i global --bun @std/encoding', async () => {
    await withTempEnv(
      ['i', 'global', '--bun', '@std/encoding'],
      async (dir) => {
        const nodeModules = path.join(dir, 'node_modules', '@std', 'encoding');
        assert.ok(
          await isDirectory(nodeMoules),
          ' node_modules path does not exist',
        );
      },
    );
  });
});

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.

jsr add command should be able to install packages globally with -g or --global CLI flag
2 participants