Skip to content

feat(plugin-commands-store): add store path command#3571

Merged
zkochan merged 1 commit intopnpm:mainfrom
jacobwgillespie:store-path
Jul 1, 2021
Merged

feat(plugin-commands-store): add store path command#3571
zkochan merged 1 commit intopnpm:mainfrom
jacobwgillespie:store-path

Conversation

@jacobwgillespie
Copy link
Copy Markdown
Contributor

Add a pnpm store path command to print the location of the pnpm store
as the CLI would resolve it. This allows the user to inspect the current
store location, as well as allows external tooling (like shell scripts)
to locate the pnpm store without needing to make assumptions about its
location or needing to load the @pnpm/store-path module.

This command differs from running pnpm get store, as pnpm get store
prints "undefined" in the case that no custom store path has been set,
which requires external tooling to have knowledge about where pnpm
locates its store in the default case.


Please let me know if you would like anything changed or improved. The test I added simply tests that pnpm store path doesn't throw an error, but if you have any pointers on how to test the logger output, I'm happy to add a test that validates the printed output. I didn't see any other examples of testing the logger output from a quick glance, though I'm not very familiar with the codebase here and could have missed something obvious.

Fixes #2575


async function pathCmd (opts: StoreCommandOptions) {
logger.info({
message: await storePath(opts.dir, opts.storeDir),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just return the string. The CLI will print it. And it is easy to cover with a test.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh nice, yes that does make things easier 👍


async function pathCmd (opts: StoreCommandOptions) {
return await storePath(opts.dir, opts.storeDir)
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you need this function at all? just run storePath at line 76

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated 👍

@jacobwgillespie
Copy link
Copy Markdown
Contributor Author

jacobwgillespie commented Jul 1, 2021

I've fixed the test failure locally

Add a `pnpm store path` command to print the location of the pnpm store
as the CLI would resolve it. This allows the user to inspect the current
store location, as well as allows external tooling (like shell scripts)
to locate the pnpm store without needing to make assumptions about its
location or needing to load the `@pnpm/store-path` module.

This command differs from running `pnpm get store`, as `pnpm get store`
prints "undefined" in the case that no custom store path has been set,
which requires external tooling to have knowledge about where pnpm
locates its store in the default case.
@zkochan zkochan merged commit f5ec0a9 into pnpm:main Jul 1, 2021
@jacobwgillespie jacobwgillespie deleted the store-path branch July 1, 2021 15:08
@zkochan zkochan added this to the v6.10 milestone Jul 6, 2021
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.

request: get default config store-dir

2 participants