Files
agent/scripts/generate-svg-sprites.js
Róbert Kiss 0f558e4132 refactore: create feature modules (#387)
* add @angular/cli to the project

* increase nodejs version -> 8.2.1

* add lerna

* merge web and shared module

* move electron module into packages as uhk-agent

Electron agent functionality is not working

* delete symlinker

* convert private properties to public of component if used in html

* revert uhk-message.component

* fix component path

* fix the correct name of the uhk-message.component.scss

* building web and electron module

* delete uhk-renderer package

* handle device connect disconnect state

* add privilege detection

* fix set privilege functionality

* turn back download keymap functionality

* add bootstrap, select2 js and fix null pointer exception

* turn back upload data to keyboard

* fix send keymap

* fix test-serializer

* add missing package.json

* merging

* fix appveyor build

* fix linting

* turn back electron storage service

* commit the missing electron-datastorage-repository

* update node to 8.3.0 in .nvmrc and log node version in appveyor build

* set exact version number in appveyor build

* vertical align privilege and missing device components

* set back node version to 8 in appveyor

* move node-usb dependency from usb dir to root

maybe it is fix the appveyor build

* revert usb to root

* fix electron builder script

* fix electron builder script

* turn off electron devtools

* remove CTRL+U functionality

* fix CTRL+o

* fix lint error

* turnoff store freeze

* start process when got `Error: EPERM: operation not permitted` error

* move files from root usb dir -> packages/usb
2017-08-19 20:02:17 +02:00

56 lines
1.5 KiB
JavaScript

const SVGSpriter = require('svg-sprite');
const path = require('path');
const mkdirp = require('mkdirp');
const fs = require('fs');
const config = {
"dest": "packages/web/src/assets/",
log: 'verbose',
'shape': {
'id': {
'generator': function (name) {
return 'icon-' + path.basename(name).slice(0, -4);
}
}
},
'mode': {
'defs': {
'inline': true,
'dest': './',
'sprite': 'compiled_sprite.svg',
bust:false
}
}
};
const spriter = new SVGSpriter(config);
// Register some SVG files with the spriter
addInputSvgs(path.join(__dirname, '../packages/web/src/svgs'));
// Compile the sprite
spriter.compile(function (error, result, cssData) {
// Run through all configured output modes
for (const mode in result) {
// Run through all created resources and write them to disk
for (const type in result[mode]) {
mkdirp.sync(path.dirname(result[mode][type].path));
fs.writeFileSync(result[mode][type].path, result[mode][type].contents);
}
}
});
function addInputSvgs(dir) {
fs.readdirSync(dir).forEach(file => {
const fullPath = path.join(dir, file);
const stat = fs.statSync(fullPath);
if (stat.isDirectory()) {
return addInputSvgs(fullPath)
}
if (path.extname(file) === '.svg') {
spriter.add(fullPath, file, fs.readFileSync(fullPath, { encoding: 'utf-8' }));
}
});
}