Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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 🥑

Awesome Lists containing this project

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