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

require() autocompletion in repl incorrectly removes file extensions from folders #14726

Closed
not-an-aardvark opened this issue Aug 10, 2017 · 0 comments
Assignees
Labels
confirmed-bug Issues with confirmed bugs. repl Issues and PRs related to the REPL subsystem.

Comments

@not-an-aardvark
Copy link
Contributor

  • Version: 8.3.0
  • Platform: macOS
  • Subsystem: repl

If a folder name ends in .js, the autocomplete suggestion in the repl will incorrectly remove the extension from the folder name.

To reproduce:

  1. mkdir foo_bar.js
  2. touch foo_bar.js/index.js
  3. node
  4. In the repl, enter require('./foo_ and press Tab

The autocomplete suggestion is require('./foo_bar') rather than require('./foo_bar.js'). Since foo_bar is a folder, removing the .js extension results in an error when calling require.

(I originally noticed this because I have a local clone of Inquirer.js, which was cloned into a folder with a .js extension.)

@not-an-aardvark not-an-aardvark added confirmed-bug Issues with confirmed bugs. repl Issues and PRs related to the REPL subsystem. labels Aug 10, 2017
@not-an-aardvark not-an-aardvark self-assigned this Aug 10, 2017
addaleax pushed a commit that referenced this issue Aug 13, 2017
When autocompleting `require` calls, the repl strips .js file extensions
from results. However, stripping an extension from a directory results
in an error. Update the autocompletion logic to avoid stripping
extensions from directories.

PR-URL: #14727
Fixes: #14726
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug Issues with confirmed bugs. repl Issues and PRs related to the REPL subsystem.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant