Skip to content

Conversation

@mbtools
Copy link
Contributor

@mbtools mbtools commented Nov 24, 2025

Some input processes require additional arguments. For example, password inputs depend on the { silent: true }. This change passes these arguments to the related input processes while keeping compatibility with existing API (i.e. callback for input.start).

cc: @wraithgar, I hope this is what you had in mind re: spinner fix.

References

Related to npm/cli#8322

@mbtools mbtools requested a review from a team as a code owner November 24, 2025 18:51
@wraithgar
Copy link
Member

I actually have a local branch w/ changes for this PR and was picking it up this week. The differences are minor and I'll add comments here.

@wraithgar
Copy link
Member

Here's my diff:

-    start: function (fn) {
-      process.emit('input', 'start')
+    start: function (fn, ...args) {
+      let endArgs = args
       function end () {
-        return process.emit('input', 'end')
+        return process.emit('input', 'end', endArgs)
       }
       if (typeof fn === 'function') {
+        process.emit('input', 'start', ...args)
         const res = fn()
         if (res && res.finally) {
           return res.finally(end)
         }
-        end()
+        end(...args)
         return res
       }
+      process.emit('input', 'start', fn, ...args)
       return end
     },
-    end: function () {
-      return process.emit('input', 'end')
+    end: function (...args) {
+      return process.emit('input', 'end', ...args)
     },

@wraithgar
Copy link
Member

TLDR; this looks fine, please don't muck about with the fn parameter like my suggestion started with.

@mbtools
Copy link
Contributor Author

mbtools commented Nov 24, 2025

I was going for consistency with the other methods. Good to see that it was close. I will rework the spinner PR once this lands.

@wraithgar wraithgar merged commit 4783d60 into npm:main Nov 25, 2025
15 checks passed
@github-actions github-actions bot mentioned this pull request Nov 25, 2025
wraithgar pushed a commit that referenced this pull request Nov 25, 2025
🤖 I have created a release *beep* *boop*
---


## [6.1.0](v6.0.0...v6.1.0)
(2025-11-25)
### Features
*
[`4783d60`](4783d60)
[#117](#117) support args for input
(#117) (@mbtools)
### Chores
*
[`f5ee8ae`](f5ee8ae)
[#114](#114) bump
@npmcli/eslint-config from 5.1.0 to 6.0.0 (#114) (@dependabot[bot])
*
[`5e6692a`](5e6692a)
[#116](#116) bump
@npmcli/template-oss from 4.28.0 to 4.28.1 (#116) (@dependabot[bot],
@npm-cli-bot)

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@mbtools mbtools deleted the input-args branch November 25, 2025 18:15
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