-
Notifications
You must be signed in to change notification settings - Fork 45
feat: replace os.system with subprocess.run and add npm install check #381
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: replace os.system with subprocess.run and add npm install check #381
Conversation
✅ Deploy Preview for fosscprogresstracker canceled.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you 🙏🏻 for contributing to progress-tracker by @FOSS-Community. Looking Forward for more contributions.
script.py
Outdated
| # Check input file exists | ||
| # ------------------------------ | ||
| if not Path(FILE_NAME).is_file(): | ||
| print(f"Error: The input file does not exist: {FILE_NAME}", file=sys.stderr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's better to raise an exception here, instead of sys.exit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay sir, i will fix both sys.exit to raise an exception.
script.py
Outdated
| # Check if npx is installed | ||
| # ------------------------------ | ||
| if not shutil.which("npx"): | ||
| print("Error: 'npx' is not installed. Please install Node.js first: https://nodejs.org/", file=sys.stderr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here also, use exception instead of sys.exit
Mr-Sunglasses
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🎊 , Thanks @ApurveKaranwal
Thank you so much, Sir! Contributing to FOSSC has been an amazing experience for me. I truly enjoyed working on this issue, learning along the way, and seeing my contribution get merged into the main branch. I’m really motivated to keep improving and contribute more in the future!🚀 |
Fixes
Fixes #380
Description
Replaced all unsafe
os.system()calls withsubprocess.run()for safer command execution and proper error handling.Added a check so that
github-readme-to-htmlis installed only if it’s missing.Technical details
subprocess.run()withcheck=Trueto catch errorsnpxavailability before running commandsdist/folder if it doesn’t existTests
python script.py -i README.md -o output.html -t "My Project"dist/github-readme-to-htmlinstalls only if missingChecklist
Update index.md).mainormaster).visible errors.