initial commit, build is not working

This commit is contained in:
Konstantin Vulsonov
2018-09-18 23:16:10 +03:00
commit 024d0e3125
12 changed files with 1395 additions and 0 deletions

42
src/app.ts Normal file
View File

@@ -0,0 +1,42 @@
import { createWriteStream, WriteStream } from 'fs';
import { join } from 'path';
import { MainConfig, SVGOConfig } from './config';
import { svgClean } from './modules/svgo.clean';
import { makeConfig } from './modules/svgo.config';
const SVGO = require('svgo');
export class SvgIconset {
private optimizeConfig: SVGOConfig;
private isValid: boolean = true;
private svgoPlugin: typeof SVGO;
constructor(private config: MainConfig) {
if (config.result === undefined || config.source === undefined) {
this.isValid = false;
}
this.optimizeConfig = config.optimize !== undefined ? makeConfig(config.optimize) : makeConfig();
this.svgoPlugin = new SVGO(this.optimizeConfig);
}
public createSet() {
if (!this.isValid) {
return console.error('Configuration is not valid, check source or result are available');
}
svgClean(this.config.source, this.svgoPlugin)
.then(files => {
createWriteStream(join(process.cwd(), this.config.source, `${this.config.result}-iconset.svg`))
.once('open', function (this: WriteStream) {
this.write(`<svg>${files}</svg>`);
})
.on('close', () => console.log(`Succesfully written file ${this.config.result}-iconset.svg`))
.on('error', () => console.error('Somethings wrong try again'));
})
.catch(err => console.error(err));
}
}