@ -1,3 +1,4 @@
/* global basedir */
const path = require ( 'path' ) ;
const URL = require ( "url" ) ;
const fs = require ( 'fs' ) ;
@ -12,7 +13,10 @@ const { PassThrough } = require('stream');
const slugify = require ( 'slugify' ) ;
const e = require ( 'express' ) ;
const dest = path . join ( appRoot , 'public/csv' ) ;
// Load project path from config/constants.js
const { basedir } = require ( '../config/constants' ) ;
const dest = path . join ( basedir , 'public/csv' ) ;
// Create a generateFilePath function witch returns a path with a filename and datetime
@ -116,12 +120,13 @@ class File extends EventEmitter {
// create a parse method which read the file and return a stream
async parse ( columns ) {
parse ( columns ) {
const stream = new PassThrough ( ) ;
// check if columns is valid
if ( ! columns || columns . length ) {
return Promise . reject ( new Error ( 'Invalid columns' ) ) ;
// return Promise.reject(new Error('Invalid columns'));
return false ;
}
// Create a variable to hold csv columns indexes