Skip to content

Commit

Permalink
avdo --> avocado
Browse files Browse the repository at this point in the history
  • Loading branch information
alexjlockwood committed Jan 22, 2018
1 parent f5d85a4 commit bba21b8
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 38 deletions.
40 changes: 20 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# avdo
# avocado

[![Build status][travis-badge]][travis-badge-url]
[![npm version][npm-badge]][npm-badge-url]
[![Coverage status][coveralls-badge]][coveralls-badge-url]

`avdo` is a command line tool (similar to [`svgo`][svgo]) that optimizes Android
`avocado` is a command line tool (similar to [`svgo`][svgo]) that optimizes Android
`VectorDrawable` (VD) and `AnimatedVectorDrawable` (AVD) xml files.

## Installation

You can install `avdo` using [npm][npm] w/ the following command:
You can install `avocado` using [npm][npm] w/ the following command:

```sh
npm install -g avdo
npm install -g avocado
```

## Usage

```text
Usage: avdo [options] [file]
Usage: avocado [options] [file]
Options:
Expand All @@ -35,31 +35,31 @@ Options:

```sh
# Optimize (and overwrite) a VD/AVD file.
avdo vector.xml
avocado vector.xml

# Optimize (and overwrite) multiple VD/AVD files.
avdo *.xml
avocado *.xml

# Optimize a VD/AVD file and write the output to a new file.
avdo vector.xml -o vector_min.xml
avocado vector.xml -o vector_min.xml

# Optimize a VD/AVD using standard input and standard output.
cat vector.xml | avdo -i - -o - > vector_min.xml
cat vector.xml | avocado -i - -o - > vector_min.xml

# Optimize (and overwrite) all of the VD/AVD files in a directory.
avdo -d path/to/directory
avocado -d path/to/directory

# Optimize all VD/AVD files in a directory and write them to a new directory.
avdo -d path/to/input/directory -o path/to/output/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.
avdo *.xml -o path/to/output/directory
avocado *.xml -o path/to/output/directory

# Pass a string as input and write the output to a new file.
avdo -s '<vector>...</vector>' -o vector_min.xml
avocado -s '<vector>...</vector>' -o vector_min.xml
```

`avdo` rewrites the `VectorDrawable` using the smallest number of `<group>`s and `<path>`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 `avdo`.
`avocado` rewrites the `VectorDrawable` using the smallest number of `<group>`s and `<path>`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

Expand Down Expand Up @@ -142,12 +142,12 @@ To test the tool, run:
npm run test
```

[travis-badge]: https://travis-ci.org/alexjlockwood/avdo.svg?branch=master
[travis-badge-url]: https://travis-ci.org/alexjlockwood/avdo
[coveralls-badge]: https://coveralls.io/repos/github/alexjlockwood/avdo/badge.svg?branch=master
[coveralls-badge-url]: https://coveralls.io/github/alexjlockwood/avdo?branch=master
[npm-badge]: https://badge.fury.io/js/avdo.svg
[npm-badge-url]: https://www.npmjs.com/package/avdo
[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
File renamed without changes.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"name": "avdo",
"version": "0.1.5",
"name": "avocado",
"version": "1.0.0",
"description": "Vector Drawable & Animated Vector Drawable optimization tool",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"bin": {
"avdo": "./bin/avdo"
"avdo": "./bin/avocado",
"avocado": "./bin/avocado"
},
"scripts": {
"prepublishOnly": "npm run build",
Expand All @@ -15,7 +16,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/alexjlockwood/avdo"
"url": "https://github.com/alexjlockwood/avocado"
},
"keywords": [
"Android",
Expand Down
4 changes: 2 additions & 2 deletions src/lib/avdo.ts → src/lib/avocado.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const batchedPlugins = (function(ps: Plugin[]) {
}
return arr;
},
[] as Plugin[][]
[] as Plugin[][],
);
})(Object.keys(plugins).map(k => plugins[k]));

Expand All @@ -58,7 +58,7 @@ export interface Options {
pretty?: boolean;
}

export class Avdo {
export class Avocado {
constructor(
private readonly options: Options = {
plugins: batchedPlugins,
Expand Down
14 changes: 7 additions & 7 deletions src/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import * as cli from 'commander';

import { Avdo, Options } from './avdo';
import { Avocado, Options } from './avocado';

import { js2xml } from './js2xml';

Expand All @@ -24,10 +24,10 @@ const writeFileFn: (
options?: string,
) => Promise<void> = promisify(fs.writeFile);

let avdo: Avdo;
let avocado: Avocado;

/**
* Runs the avdo command line tool.
* Runs the avocado command line tool.
*/
export async function run() {
const pkgJson: {
Expand Down Expand Up @@ -92,7 +92,7 @@ export async function run() {
}
}

avdo = new Avdo();
avocado = new Avocado();

if (output) {
if (input && input[0] !== '-') {
Expand Down Expand Up @@ -208,7 +208,7 @@ function processData(
const startTime = Date.now();
const prevFileSize = Buffer.byteLength(data, 'utf8');

return avdo.optimize(data).then(result => {
return avocado.optimize(data).then(result => {
// if (config.datauri) {
// result.data = encodeSVGDatauri(result.data, config.datauri);
// }
Expand Down Expand Up @@ -322,7 +322,7 @@ function printErrorAndExit(error: any) {

// // Flatten an array of plugins grouped per type, sort and write output
// var list = [].concat
// .apply([], new Avdo().config.plugins)
// .apply([], new Avocado().config.plugins)
// .sort((a, b) => a.name.localeCompare(b.name))
// .map(plugin => ` [ ${plugin.name.green} ] ${plugin.description}`)
// .join('\n');
Expand All @@ -331,7 +331,7 @@ function printErrorAndExit(error: any) {

/*
npm run build && \
node bin/avdo --multipass -s \
node bin/avocado --multipass -s \
'
<?xml version="1.0" encoding="utf-8"?>
<vector
Expand Down
8 changes: 4 additions & 4 deletions test/plugins/_plugins.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Avdo, plugins } from '../../src/lib/avdo';
import { Avocado, plugins } from '../../src/lib/avocado';

import { Plugin } from '../../src/plugins/_types';
import { expect } from 'chai';
Expand Down Expand Up @@ -27,7 +27,7 @@ describe('plugin tests', () => {
const orig = splitted[0];
const should = splitted[1];
const params = splitted[2];
let avdo: Avdo;
let avocado: Avocado;

const plugin = plugins[name];
const origActive = plugin.active;
Expand All @@ -36,11 +36,11 @@ describe('plugin tests', () => {
if (params) {
plugin.params = { ...origParams, ...JSON.parse(params) };
}
avdo = new Avdo({
avocado = new Avocado({
plugins: [[plugin]],
pretty: true,
});
const result = avdo.optimize(orig).then(res => {
const result = avocado.optimize(orig).then(res => {
normalize(res).should.be.equal(should);
});
plugin.active = origActive;
Expand Down

1 comment on commit bba21b8

@slavasav
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Fragmented way =))

Please sign in to comment.