Added new CLI and convertFile method to API #8
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.
This PR delivers what was requested in #2.
I've added a new CLI which has the following usage:
I've also added a new
convertFile
method to the API which is utilized by the CLI but, I believe, will also be useful to consumers.CLI
The CLI can work in the following ways:
.svg
/.pony
), is replaced with.png
-f, --filename
option is specified, the resulting PNG buffer will be written to that fileprocess.cwd()
is used as default base URLThe
-b, --base-url
option will always take precedence over the defaults mentioned above.convertFile(sourceFilePath[, options])
The new
convertFile
API method is a simple wrapper around the existingconvert
method that reads the SVG buffer from a specified file path and writes the converted PNG buffer to another file path. It takes the same options with the additional of atargetFilePath
option, which can be specified to control where the PNG buffer is written. If omitted, the target file will be derived fromsourceFilePath
in the same way as described in the first point of the CLI section above.It's also worth noting that, if the
baseFile
andbaseUrl
options are both omitted, a file URL created fromsourceFilePath
will be used as the base URL instead of defaulting toprocess.cwd()
as is done for the standardconvert
method.