Skip to content

[Feature] Replace os.system() with subprocess.run() and improve npm installation check #380

@ApurveKaranwal

Description

@ApurveKaranwal

Problem

The current script uses os.system() to run commands, which is:

  1. Unsafe (can lead to shell injection).
  2. Doesn’t capture errors or output properly.
  3. Installs github-readme-to-html every time, even if it’s already installed, wasting time and bandwidth.

Description

Replace os.system() with subprocess.run() and implement a check so that github-readme-to-html is installed only if it’s not already installed.

Benefits:

  1. Safer command execution.
  2. Proper error handling with exit codes.
  3. Avoids unnecessary npm installations

Alternatives

Keep using os.system() and reinstall the package every time (current behavior).
The proposed solution is safer, more efficient, and user-friendly.

Additional context

Currently, the script always reinstalls github-readme-to-html and uses os.system(), which is unsafe and doesn’t provide proper error handling.
Using subprocess.run() with a check for existing npm installations will make the script safer, faster, and more user-friendly.

Implementation

Replace all os.system() calls with subprocess.run().
Check if github-readme-to-html is already installed before attempting installation.
Handle errors using specific exceptions like subprocess.CalledProcessError.
Update user messages to clearly indicate progress and errors.

  • I would be interested in implementing this feature.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions