diff --git a/src/app.ts b/src/app.ts index 86d8956..bba9acb 100644 --- a/src/app.ts +++ b/src/app.ts @@ -33,17 +33,19 @@ export class SvgIconset { const ids = optimizedResponse.map(el => el.id); Promise.all(optimizedResponse.map(el => el.optimized)) .then(resFiles => { - createWriteStream(join(process.cwd(), this.config.source, `${this.config.result}-iconset.svg`)) + const resultFile = join(process.cwd(), this.config.source, `${this.config.result}-iconset.svg`); + createWriteStream(resultFile) .once('open', function (this: WriteStream) { try { const data = resFiles.map(res => res.data.replace(/${data.join('')}`); idx++; + this.end(); } catch (err) { console.log('ERROR', err); } }) - .on('close', () => console.log(`Succesfully written file ${this.config.result}-iconset.svg`)) + .on('close', () => console.log(`Succesfully written file ${resultFile}`)) .on('error', () => console.error('Something’s wrong try again')); }) .catch(console.error);