swpm icon indicating copy to clipboard operation
swpm copied to clipboard

Global pins?

Open bernardoadc opened this issue 2 years ago • 3 comments

Prerequisites

Please answer the following questions for yourself before submitting an issue.

  • [ ] I am running the latest version
  • [x] I checked to make sure that this command request has not already been filed

Command to add

This is first a doubt, more than an addition. Does the pin command work only for current project or is there a way to "pin it globally"? If both are available, this would mean that having pnpm pinned globally would automatically work for any project. But if some project has pinned npm, then that would be preferred in it.

Expected Result

swpm --pin --global pnpm
mkdir someproject
cd someproject
swpm install # will use pnpm automatically

Context

I'm learning the tool first. If anything, this should help improve the docs.

bernardoadc avatar Dec 09 '22 04:12 bernardoadc

Hi @bernardoadc there is no global pin command. But you can set a package manager by default with an environment variable.

equiman avatar Dec 09 '22 15:12 equiman

I've created a new section on readme (and menu) to easy access.

https://github.com/deinsoftware/swpm#default

Let me know if this solves your doubt.

I will try to add soon a command to do this task, but I'm not sure if node.js support set environment variables on each OS.

equiman avatar Dec 09 '22 16:12 equiman

It can't be created or updated OS environment variables directly with node.js (only read). https://nodejs.org/api/process.html#process_process_env

So, it will need to be set manually as described on the readme.

equiman avatar Dec 11 '22 18:12 equiman

great @equiman ! Sorry for the late response.

I believe it should have a way of setting it with spawn (I think package cross-env does that), but setting the variable manually is equally fine!

bernardoadc avatar Jan 05 '23 04:01 bernardoadc

Thanks for the recommendation, I will take a look before finishing a new feature about aliases.

https://www.npmjs.com/package/cross-env

equiman avatar Jan 13 '23 16:01 equiman