Skip to content
Snippets Groups Projects
Commit 13b03e26 authored by Alexander Slansky's avatar Alexander Slansky
Browse files

adds watch option to cli

parent b92132d7
No related branches found
No related tags found
No related merge requests found
......@@ -3,3 +3,4 @@ coverage
.DS_Store
*.log
build
test/dist
......@@ -2,36 +2,34 @@
'use strict';
var sprite = require('../index');
var gaze = require('gaze');
var opts = require('nomnom')
.option('src', {
position: 0,
abbr: 's',
required: true,
list: true,
metavar: 'GLOB',
help: 'glob strings to find source images to put into the sprite'
})
.option('out', {
position: 0,
abbr: 'o',
required: true,
metavar: 'DIR',
default: process.cwd(),
help: 'path of directory to write sprite file to'
})
.option('name', {
abbr: 'n',
default: 'sprite.png',
help: 'name of the sprite file'
})
.option('style', {
abbr: 'st',
help: 'file to write css to, if ommited no css is written'
.option('src', {
position: 1,
abbr: 's',
required: true,
list: true,
metavar: 'GLOB',
help: 'glob strings to find source images to put into the sprite'
})
.option('cssPath', {
abbr: 'c',
full: 'css-image-path',
default: '../images',
help: 'http path to images on the web server (relative to css path or absolute)'
help: 'http path to images on the web server (relative to css path or absolute path)'
})
.option('name', {
abbr: 'n',
default: 'sprite.png',
help: 'name of the sprite file'
})
.option('processor', {
abbr: 'p',
......@@ -39,16 +37,37 @@ var opts = require('nomnom')
default: 'css',
help: 'output format of the css. one of css, less, sass, scss or stylus'
})
.option('orientation', {
choices: ['vertical', 'horizontal'],
default: 'vertical',
help: 'orientation of the sprite image'
.option('style', {
abbr: 'st',
help: 'file to write css to, if ommited no css is written'
})
.option('watch', {
abbr: 'w',
flag: true,
help: 'continuously create sprite'
})
.option('margin', {
default: 5,
help: 'margin in px between tiles'
})
.option('orientation', {
choices: ['vertical', 'horizontal'],
default: 'vertical',
help: 'orientation of the sprite image'
})
.script('css-sprite')
.parse();
sprite.create(opts);
if (opts.watch) {
gaze(opts.src, function () {
console.log('Watching for file changes ...')
this.on('all', function () {
sprite.create(opts, function () {
console.log('> Sprite created in ' + opts.out);
});
});
});
}
else {
sprite.create(opts);
}
......@@ -56,7 +56,8 @@
"vinyl": "~0.2.3",
"event-stream": "~3.1.0",
"graceful-fs": "~2.0.1",
"mkdirp": "~0.3.5"
"mkdirp": "~0.3.5",
"gaze": "~0.5.0"
},
"devDependencies": {
"mocha": "~1.17.0",
......
......@@ -29,18 +29,19 @@ npm install css-sprite -g
## Command Line Interface
```
Usage: css-sprite <src>... [options]
Usage: css-sprite <out> <src>... [options]
out path of directory to write sprite file to
src glob strings to find source images to put into the sprite
Options:
-o DIR, --out DIR path of directory to write sprite file to [process.cwd()]
-c, --css-image-path http path to images on the web server (relative to css path or absolute path) [../images]
-n, --name name of the sprite file [sprite.png]
-st, --style file to write css to, if ommited no css is written
-c, --css-image-path http path to images on the web server (relative to css path or absolute) [../images]
-p, --processor output format of the css. one of css, less, sass, scss or stylus [css]
--orientation orientation of the sprite image [vertical]
-st, --style file to write css to, if ommited no css is written
-w, --watch continuously create sprite
--margin margin in px between tiles [5]
--orientation orientation of the sprite image [vertical]
```
## Programatic usage
......
sprite.png

1.78 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment