Skip to content

Commit

Permalink
breaking change: the CLI does not provide the possibility for piping
Browse files Browse the repository at this point in the history
into a file. Just use `imacss *.svg > images.css`
  • Loading branch information
André König committed Jun 14, 2015
1 parent c87cef4 commit d90808a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 24 deletions.
32 changes: 12 additions & 20 deletions bin/imacss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* imacss
*
* Copyright(c) 2014 André König <andre.koenig@posteo.de>
* Copyright(c) 2014 - 2015 André König <andre.koenig@posteo.de>
* MIT Licensed
*
*/
Expand All @@ -13,15 +13,16 @@
*
*/

var fs = require('fs'),
path = require('path'),
imacss = require('../'),
pkg = require('../package.json'),
args = {
glob: process.argv[2],
cssfile: process.argv[3],
cssclass: process.argv[4]
};
'use strict';

var path = require('path');
var imacss = require('../');

var pkg = require('../package.json');
var args = {
glob: process.argv[2],
cssclass: process.argv[4]
};

/**
* Prints an error message to the console and exits
Expand Down Expand Up @@ -73,20 +74,11 @@ if ('version' === args.glob) {
return console.log(pkg.version);
}

//
// Check if a css file has been defined.
//
if (args.cssfile && !isPath(args.cssfile)) {
args.cssclass = args.cssfile;

delete args.cssfile;
}

args.glob = normalizePath(args.glob);

imacss
.transform(args.glob, args.cssclass)
.on('error', function (err) {
error('Converting images failed: ' + err);
})
.pipe(args.cssfile ? fs.createWriteStream(args.cssfile) : process.stdout);
.pipe(process.stdout);
File renamed without changes.
10 changes: 6 additions & 4 deletions README.md → readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,24 @@ Embed all SVGs in a particular directory and all its subdirectories (will pipe t

Embed all SVGs in a particular directory and transfer them to a CSS file which will be saved in the CWD.

$ imacss "~/projects/webapp/images/*.svg" images.svg.css
$ imacss "~/projects/webapp/images/*.svg" > images.svg.css

Embed all SVGs _and_ PNGs in a particular directory and transfer them to a CSS file which will be saved in the CWD.

$ imacss "~/projects/webapp/images/*.{svg,png}" images.css
$ imacss "~/projects/webapp/images/*.{svg,png}" > images.css

If you don't like the `imacss` selector namespace you are able to modify it as well.

$ imacss "~/projects/webapp/images/*.{svg,png}" images.css foobar
$ imacss "~/projects/webapp/images/*.{svg,png}" foobar > images.css

will produce this selector structure in the CSS file:

```css
.foobar.foobar-github {...}
```

**Important:** Please note that `imacss` does not embed `image/svg+xml` as `base64` strings. Instead it will use the raw `utf-8` representation.

## API

If you would like to use the `imacss` functionality within your application, there is an API for that.
Expand Down Expand Up @@ -124,4 +126,4 @@ imacss

## Author

Copyright 2014-2015, [André König](http://andrekoenig.info) (andre.koenig@posteo.de)
Copyright 2014 - 2015, [André König](http://andrekoenig.info) (andre.koenig@posteo.de)

0 comments on commit d90808a

Please sign in to comment.