async function commit(spreadsheetId, options, sheetService = new SheetService(spreadsheetId, options)) {
  let data;
  const { filePath = METRICS_FILE, clientEmail, privateKey } = options;
  try {
    data = readMetricFile(filePath);
  } catch (err) {
    console.error(`Metrics file was not found: ${filePath}`, err);
    return;
  }

  await sheetService.authorize({ clientEmail, privateKey });

  // Check if the first row has data.
  try {
    await sheetService.addData(data);
  } catch (err) {
    console.error(err);
  } finally {
    cleanup(filePath);
  }
}
/**
 * Attempts to write to Google sheets using the credentials supplied. Asynchronous (returns a Promise)
 * @param spreadsheetId {string}
 * @param options {object}
 * @param options.clientEmail {string}
 * @param options.dateFormat {string}   Used by the sheetService
 * @param options.filePath {string}
 * @param options.privateKey {string}
 * @param sheetService {SheetService}
 */
Attempts to write to Google sheets using the credentials supplied.
Attempts to write to Google sheets using the credentials supplied .
async function commit(spreadsheetId, options, sheetService = new SheetService(spreadsheetId, options)) {
  let data;
  const { filePath = METRICS_FILE, clientEmail, privateKey } = options;
  try {
    data = readMetricFile(filePath);
  } catch (err) {
    console.error(`Metrics file was not found: ${filePath}`, err);
    return;
  }
  await sheetService.authorize({ clientEmail, privateKey });
  try {
    await sheetService.addData(data);
  } catch (err) {
    console.error(err);
  } finally {
    cleanup(filePath);
  }
}
async function commit ( spreadsheetId , options , sheetService = new SheetService ( spreadsheetId , options ) ) { let data ; const { filePath = METRICS_FILE , clientEmail , privateKey } = options ; try { data = readMetricFile ( filePath ) ; } catch ( err ) { console . error ( ` ${ filePath } ` , err ) ; return ; } await sheetService . authorize ( { clientEmail , privateKey } ) ; try { await sheetService . addData ( data ) ; } catch ( err ) { console . error ( err ) ; } finally { cleanup ( filePath ) ; } }
Attempts to write to Google sheets using the credentials supplied.
Attempts to write to Google sheets using the credentials supplied .
// Check if the first row has data.