Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alexjlockwood/avocado
🥑 Vector Drawable optimization tool 🥑
https://github.com/alexjlockwood/avocado
android animated-vector-drawable vector-drawable
Last synced: 2 days ago
JSON representation
🥑 Vector Drawable optimization tool 🥑
- Host: GitHub
- URL: https://github.com/alexjlockwood/avocado
- Owner: alexjlockwood
- License: mit
- Created: 2017-11-14T22:01:45.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2020-04-29T22:14:34.000Z (over 4 years ago)
- Last Synced: 2024-12-14T00:06:18.662Z (9 days ago)
- Topics: android, animated-vector-drawable, vector-drawable
- Language: TypeScript
- Homepage:
- Size: 336 KB
- Stars: 1,351
- Watchers: 26
- Forks: 48
- Open Issues: 32
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-list - alexjlockwood/avocado - 🥑 Vector Drawable optimization tool 🥑 (TypeScript)
README
# avocado
[![Build status][travis-badge]][travis-badge-url]
[![npm version][npm-badge]][npm-badge-url]
[![Coverage status][coveralls-badge]][coveralls-badge-url]`avocado` is a command line tool (similar to [`svgo`][svgo]) that optimizes Android
`VectorDrawable` (VD) and `AnimatedVectorDrawable` (AVD) xml files.## Installation
You can install `avocado` using [npm][npm] w/ the following command:
```sh
npm install -g avocado
```## Usage
```text
Usage: avocado [options] [file]Options:
-V, --version output the version number
-s, --string input VD or AVD string
-i, --input input file/directory, or "-" for STDIN
-o, --output output file/directory (same as the input file by default), or "-" for STDOUT
-d, --dir optimizes and rewrite all *.xml files in a directory
-q, --quiet only output error messages
-h, --help output usage information
```### Examples
```sh
# Optimize (and overwrite) a VD/AVD file.
avocado vector.xml# Optimize (and overwrite) multiple VD/AVD files.
avocado *.xml# Optimize a VD/AVD file and write the output to a new file.
avocado vector.xml -o vector_min.xml# Optimize a VD/AVD using standard input and standard output.
cat vector.xml | avocado -i - -o - > vector_min.xml# Optimize (and overwrite) all of the VD/AVD files in a directory.
avocado -d path/to/directory# Optimize all VD/AVD files in a directory and write them to a new directory.
avocado -d path/to/input/directory -o path/to/output/directory# Optimize all files ending with '.xml' and write them to a new directory.
avocado *.xml -o path/to/output/directory# Pass a string as input and write the output to a new file.
avocado -s '...' -o vector_min.xml
````avocado` rewrites the `VectorDrawable` using the smallest number of ``s and ``s possible, reducing their file sizes and making them faster to parse and draw at runtime. The example below shows the contents of a `VectorDrawable` before and after being run through `avocado`.
#### Before
```xml
```
#### After
```xml
```
## Build instructions
If you want to contribute, first be sure to install the latest version of
[`Node.js`](https://nodejs.org/) and [`npm`](https://www.npmjs.com/).
If you're not sure what IDE to use, I highly recommend checking out
[vscode][vscode].Then clone this repository and in the root directory, run:
```sh
npm install
```To build the tool, run:
```sh
npm run build
```To test the tool, run:
```sh
npm run test
```[travis-badge]: https://travis-ci.org/alexjlockwood/avocado.svg?branch=master
[travis-badge-url]: https://travis-ci.org/alexjlockwood/avocado
[coveralls-badge]: https://coveralls.io/repos/github/alexjlockwood/avocado/badge.svg?branch=master
[coveralls-badge-url]: https://coveralls.io/github/alexjlockwood/avocado?branch=master
[npm-badge]: https://badge.fury.io/js/avocado.svg
[npm-badge-url]: https://www.npmjs.com/package/avocado
[svgo]: https://github.com/svg/svgo
[vscode]: https://code.visualstudio.com/
[npm]: https://www.npmjs.com/get-npm