ascentiaci / ascentiaci.ca

Ascentia Career Institute Main Marketing Site
1 stars 1 forks source link

I'm pretty certain this will solve the issues in issue Website issue … #60

Closed fireball8931 closed 3 weeks ago

fireball8931 commented 3 weeks ago

…- from Michael - 2024-06-09T02:11:31.571Z #58

trunk-io[bot] commented 3 weeks ago

Merging to main in this repository is managed by Trunk.

cloudflare-pages[bot] commented 3 weeks ago

Deploying ascentiaci-ca with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0204226
Status: ✅  Deploy successful!
Preview URL: https://114ca314.ascentiaci-ca.pages.dev
Branch Preview URL: https://58-website-issue-from-michae.ascentiaci-ca.pages.dev

View logs

cloudflare-pages[bot] commented 3 weeks ago

Deploying elevareci-ca with  Cloudflare Pages  Cloudflare Pages

Latest commit: 0204226
Status: ✅  Deploy successful!
Preview URL: https://a1d08fe0.elevareci-ca.pages.dev
Branch Preview URL: https://58-website-issue-from-michae.elevareci-ca.pages.dev

View logs

github-actions[bot] commented 3 weeks ago

Risk Level 2 - /home/runner/work/ascentiaci.ca/ascentiaci.ca/scripts/json2csvScript.js

  1. Error Handling: The error handling could be improved by providing more context-specific messages. For example, instead of just logging 'Error reading the JSON file:', you could include the file name.
fs.readFile(inputFile, \"utf8\", (err, data) => {
  if (err) {
    console.error(`Error reading the JSON file ${inputFile}:`, err);
    return;
  }
  // ...
});
  1. Callback Hell: The nested callbacks can be refactored using Promises or async/await for better readability and maintainability.
const fs = require(\"fs\").promises;
const { Parser } = require(\"json2csv\");

async function jsonToCsv(inputFile, outputFile) {
  try {
    const data = await fs.readFile(inputFile, \"utf8\");
    const jsonData = JSON.parse(data);
    const parser = new Parser();
    const csv = parser.parse(jsonData);
    await fs.writeFile(outputFile, csv);
    console.log(\"CSV file has been created successfully.\");
  } catch (err) {
    console.error(\"Error:\", err);
  }
}

jsonToCsv(\"program-info.json\", \"pg-output.csv\");
  1. Magic Strings: Consider using constants for file paths to avoid magic strings.
const INPUT_FILE = \"program-info.json\";
const OUTPUT_FILE = \"pg-output.csv\";

jsonToCsv(INPUT_FILE, OUTPUT_FILE);

🔧📈📜


Powered by Code Review GPT