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: function to return content of completion script #11

Merged
merged 8 commits into from
Jan 30, 2024

Conversation

KSXGitHub
Copy link

No description provided.

@KSXGitHub KSXGitHub changed the title feat: add option to print shell config feat: print completion to stdout Jan 30, 2024
@KSXGitHub KSXGitHub marked this pull request as ready for review January 30, 2024 15:40
- '14'
node:
- '20'
- '21'
Copy link
Member

Choose a reason for hiding this comment

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

if it will be shipped to pnpm v9
at least v18 should be supported

lib/index.js Outdated
if (!completer) throw new TypeError('options.completer is required');
if (!shell) throw new TypeError('options.shell is required');
const completionScriptContent = await installer.getCompletionScript({ name, completer, shell });
console.log(completionScriptContent)
Copy link
Member

Choose a reason for hiding this comment

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

it would make more sense to return the output that pnpm would print out.

@zkochan
Copy link
Member

zkochan commented Jan 30, 2024

I don't get it. The completion script is written to the fs, then read and written to the output? Why is it not generated in memory instead and returned from memory?

@KSXGitHub
Copy link
Author

KSXGitHub commented Jan 30, 2024

I don't get it. The completion script is written to the fs, then read and written to the output? Why is it not generated in memory instead and returned from memory?

The completion script must be exist in the filesystem as a file for the shell programs to load. But what pnpm/pnpm#3083 requests is for the user to install it themselves, because letting pnpm guesses the system can be error-prone.

@zkochan
Copy link
Member

zkochan commented Jan 30, 2024

The completion script must be exist in the filesystem as a file for the shell programs to load.

But the referenced issue is exactly about not writing to the fs anything.

@KSXGitHub
Copy link
Author

But the referenced issue is exactly about not writing to the fs anything.

It is about pnpm not writing to fs for the users. The users themselves must write to fs.

@KSXGitHub KSXGitHub changed the title feat: print completion to stdout feat: function to return content of completion script Jan 30, 2024
@zkochan
Copy link
Member

zkochan commented Jan 30, 2024

I misunderstood the readFile line. It reads the template file that is shipped with pnpm.

@KSXGitHub
Copy link
Author

I misunderstood the readFile line. It reads the template file that is shipped with pnpm.

It was a terrible name. Fortunately, I wasn't deceived (somehow).

@zkochan zkochan merged commit a0eeee8 into main Jan 30, 2024
6 checks passed
@KSXGitHub KSXGitHub deleted the print-completion branch January 30, 2024 16:39
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.

2 participants