Feature/recursive #22
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
With the traditional glob method of taking input, we could use wildcards to specify that files in subfolders should be converted together, but the output folder would store all the files together without any existing file structure distinction. This was not only a pain in the ass, but also caused the conversion to be missed if files with the same name were found in different folders, so I added the
--recursiveoption.To make it easier to understand the relative paths of the input and target files, I wanted to limit
--inputto specifying the target folder and separate the option to specify an extension into--target. However, it is still possible to utilize traditional wildcards. In the long run, I would suggest limiting or separating the functionality completely.This pull request includes significant updates to the
lib/cli.jsandlib/convert.jsfiles to enhance the functionality and usability of the image conversion tool. The most important changes include adding new options for specifying input and output directories, handling recursive directory processing, and ensuring output directories exist before writing files. Additionally, a minor dependency update was made inpackage.json.Enhancements to command-line options:
lib/cli.js: Changed theinputoption to accept an input directory and added atargetoption to specify file extensions for conversion.lib/cli.js: Added arecursiveoption to process subdirectories recursively and provided aliases for the new options.Improvements to file handling:
lib/convert.js: Adjusted the output path handling to support recursive mode and ensured the output directory exists before writing files.