add delimiter as option #9

Merged
vargburz merged 2 commits from handle-optional-csv-delimeters into master 2 years ago
  1. 2
      package.json
  2. 2
      src/services/exporter.ts
  3. 1
      src/types.ts

2
package.json

@ -1,6 +1,6 @@
{ {
"name": "grafana-data-exporter", "name": "grafana-data-exporter",
"version": "0.7.1", "version": "0.7.2",
"description": "Server for fetching data from Grafana datasources", "description": "Server for fetching data from Grafana datasources",
"scripts": { "scripts": {
"start": "node dist/server.js", "start": "node dist/server.js",

2
src/services/exporter.ts

@ -109,7 +109,7 @@ export class Exporter {
} }
private _initCsvStream() { private _initCsvStream() {
const csvStream = csv.createWriteStream({ headers: true }) const csvStream = csv.createWriteStream({ headers: true, delimiter: this._task.csvDelimiter })
.on('error', async e => await this._updateProgress({ status: ExportStatus.ERROR, errorMessage: e.message })); .on('error', async e => await this._updateProgress({ status: ExportStatus.ERROR, errorMessage: e.message }));
const writableStream = fs.createWriteStream(this._getFilePath('csv')); const writableStream = fs.createWriteStream(this._getFilePath('csv'));

1
src/types.ts

@ -102,6 +102,7 @@ export type ExportTask = {
from: number; from: number;
to: number; to: number;
}; };
csvDelimiter: string;
progress?: ExportProgress; progress?: ExportProgress;
id?: string; id?: string;
}; };

Loading…
Cancel
Save