Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kocatepedogu committed Sep 23, 2023
1 parent a072750 commit a6209f0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 10 additions & 6 deletions src/main/io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export function initializeAppData() {

appDataDir = path.join(appDataDir, 'sounding-viewer');
if (!fs.existsSync(appDataDir)) {
fs.mkdirSync(appDataDir);
fs.mkdirSync(appDataDir, { recursive: true });
}
}

Expand Down Expand Up @@ -124,17 +124,21 @@ export function wgrib2(gribfile: string) {
const gribFilename = `${path.join(appDataDir, gribfile)}`;

return new Promise<string[][]|Error>((resolve) => {
exec(`wgrib2 -csv ${csvFilename} ` + gribFilename, (err) => {
exec(`wgrib2 -csv ${csvFilename} ${gribFilename}`, (err) => {
fs.unlinkSync(gribFilename);

if (err) {
Promise.resolve(new Error('wgrib2 returned an error'));
return resolve(new Error('wgrib2 returned an error'));
}

fs.readFile(`${csvFilename}`, 'utf8', (err, data:string) => {
fs.unlinkSync(csvFilename);

if (err) {
resolve(new Error('An error occured while reading the CSV file produced by wgrib2'));
return resolve(new Error('An error occured while reading the CSV file produced by wgrib2'));
}

resolve(data.split('\n')
return resolve(data.split('\n')
.map((e: string) => e.split(',')
.slice(2)
.map(str => str.replaceAll('"',''))));
Expand Down
4 changes: 4 additions & 0 deletions src/renderer/rucsoundings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ export async function fetchGFS(params: URLSearchParams) {
const result = await fetch(fetchURL);
const text = await result.text();

if (text == '') {
throw new Error('rucsoundings server did not return any data for given hour and location');
}

return GSD.parse(text);
}

Expand Down

0 comments on commit a6209f0

Please sign in to comment.