Add ability to suppress `.command`s in REPL
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- JavaScript
- Estrellas
- 122k
- Forks
- 37.4k
- Merge medio
- 4 d 2 h
- PR fusionados (30 d)
- 283
Descripción
What is the problem this feature will solve?
I'm building a custom shell-like REPL for an application that's written in Javascript. To achieve this, I'm using the REPL module because it's more feature-rich than the readline module (for example, using ctrl+r (and looking through the Node code, I couldn't actually find where this functionality is defined...)). It's also much easier to work with than the readline module.
However, I'm trying to secure the application as best as possible so my users don't fall into holes when trying to execute commands, and so I'm restricting access to the REPL dot commands of .editor, .help, etc. I would also like to take advantage of the .commands in my own eval function so I can also extend the functionality of my REPL too.
Specifically: the problem this feature will solve is to allow .commands through to the eval function. Some guard rails will probably need to be put in place (such as making sure the default eval isn't being used, or writing a warning in the docs).
What is the feature you are proposing to solve the problem?
Add an optional property to the ReplOptions called nativeDotCommands (or whatever fits), and adjust the if statement to account for this property (and likely adjustments to other parts of the codebase)
What alternatives have you considered?
Currently, I'm setting repl.commands = {} to remove all the commands, however of course this is throwing an error from my linter because that property is read-only. I can suppress the error, but that still doesn't allow me to use .commands within my application. So far, this is the best work around I've got (short of rewriting and using the readline module.)
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza en la instrucción if enlazada de lib/repl.js e inspecciona la definición de ReplOptions y cómo se expone repl.commands. Traza cómo se gestionan actualmente los comandos de punto y, a continuación, determina cómo una configuración opcional nativeDotCommands podría permitir que lleguen a un eval personalizado sin debilitar el comportamiento predeterminado. Se considerará terminado cuando las REPL personalizadas puedan recibir comandos de punto mientras se mantiene protegida la gestión predeterminada existente.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- javascript
- Área
- cli
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Tranquilo
- Claridad
- Bastante claro
- Aptitud para principiantes
- 48/100