├── bin ├── svgstore.cmd └── svgstore ├── .gitignore ├── CHANGELOG.md ├── README.md ├── package.json └── LICENSE /bin/svgstore.cmd: -------------------------------------------------------------------------------- 1 | @node "%~dpn0" %* 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .nyc_output/ 2 | coverage/ 3 | node_modules/ 4 | 5 | *.log 6 | .*.swp 7 | .npmignore 8 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # v1.3.1 2 | 3 | * Set `--inline` as boolean flag 4 | * Add default values to cli args 5 | 6 | # v1.3.0 7 | 8 | * Updated to svgstore 2.0.2 9 | * Support `--inline` when outputting to a file 10 | 11 | # v1.2.1 12 | 13 | * Fix regression with prefix defaulting to "undefined" 14 | 15 | # v1.2.0 16 | 17 | * Moved argument parsing to use yargs-parser 18 | * Added `--inline` option to stop generating XML preamble 19 | 20 | # v1.1.0 21 | 22 | * Add `-p` flag for prefixing symbols 23 | 24 | 25 | # v1.0.0 26 | 27 | * Initial release 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # svgstore-cli 2 | 3 | A command-line tool for combining SVG files into a single sprite sheet using 4 | `` tags. 5 | 6 | ## Installation 7 | 8 | ``` 9 | npm install -g svgstore-cli 10 | ``` 11 | 12 | ## Usage 13 | 14 | ``` 15 | svgstore [-o OUTFILE] [-p PREFIX] [--inline] INPUT ... 16 | ``` 17 | 18 | * Multiple input files can be specified 19 | * Input files can be globs (e.g., `**/*.svg`) 20 | * Output to stdout by default 21 | * Can direct output to a file with the `-o outfile` flag 22 | * Can prefix the symbol names using the `-p prefix` flag 23 | * Supports `--inline` to avoid generating XML doctype 24 | 25 | --- 26 | 27 | Licensed under [MIT](https://github.com/svgstore/svgstore-cli/blob/master/LICENSE) 28 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "svgstore-cli", 3 | "version": "2.0.1", 4 | "description": "Combine all your SVGs into one using ", 5 | "main": "./bin/svgstore", 6 | "bin": { 7 | "svgstore": "./bin/svgstore" 8 | }, 9 | "scripts": {}, 10 | "repository": { 11 | "type": "git", 12 | "url": "git+https://github.com/svgstore/svgstore-cli.git" 13 | }, 14 | "keywords": [ 15 | "svg", 16 | "svgstore" 17 | ], 18 | "author": "Darryl Pogue ", 19 | "license": "MIT", 20 | "bugs": { 21 | "url": "https://github.com/svgstore/svgstore-cli/issues" 22 | }, 23 | "homepage": "https://github.com/svgstore/svgstore-cli#readme", 24 | "dependencies": { 25 | "glob": "^7.2.0", 26 | "svgstore": "^3.0.1", 27 | "yargs-parser": "^20.2.9" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Darryl Pogue 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /bin/svgstore: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 'use strict'; 3 | 4 | var fs = require('fs'); 5 | var path = require('path'); 6 | var glob = require('glob'); 7 | var svgstore = require('svgstore'); 8 | var yargs = require('yargs-parser'); 9 | 10 | 11 | // Define the available command-line options 12 | var argv_options = { 13 | alias: { inline: ['i'], output: ['o'], prefix: ['p'] }, 14 | default: { inline: false, output: '', prefix: '' }, 15 | boolean: ['inline'] 16 | }; 17 | 18 | 19 | // Parse the command-line arguments 20 | var args = yargs(process.argv.slice(2), argv_options); 21 | 22 | var output = args.output; 23 | var prefix = args.prefix; 24 | var inline = args.inline; 25 | var inputs = []; 26 | 27 | 28 | // Make an array of all the inputs, expanding globs 29 | var inputs = args._.reduce(function(total, files) { 30 | return total.concat(glob.sync(files)); 31 | }, []); 32 | 33 | 34 | if (inputs.length == 0) { 35 | console.error('No input files provided'); 36 | return -1; 37 | } 38 | 39 | 40 | // Build up the spritesheet 41 | var sprites = inputs.reduce(function(sprites, file) { 42 | return sprites.add(prefix + path.basename(file, '.svg'), fs.readFileSync(file, 'utf8')); 43 | }, svgstore({ inline: inline })); 44 | 45 | 46 | // Output to file, or to stdout 47 | if (output) { 48 | fs.writeFileSync(output, sprites.toString({ inline: inline })); 49 | } else { 50 | console.log(sprites.toString({ inline: inline })); 51 | } 52 | --------------------------------------------------------------------------------