From 1219c1610a542914bd3cc7a30b1f2f536c9048ab Mon Sep 17 00:00:00 2001 From: miles-grant-ibigroup Date: Wed, 5 Jul 2023 14:35:54 -0400 Subject: [PATCH 1/2] fix: Support overriding `custom_name.txt` --- webhook/processConfig.ts | 14 ++++++++++++++ webhook/utils.ts | 1 + 2 files changed, 15 insertions(+) diff --git a/webhook/processConfig.ts b/webhook/processConfig.ts index 8fb9706..386f665 100644 --- a/webhook/processConfig.ts +++ b/webhook/processConfig.ts @@ -1,5 +1,6 @@ /* eslint-disable complexity */ import { setTimeout as setPromisedTimeout } from 'timers/promises' +import { writeFile } from 'fs' import { createFile as touch, readJSON, remove, writeJSON } from 'fs-promise' import execa, { ExecaChildProcess, ExecaSyncReturnValue } from 'execa' @@ -84,6 +85,19 @@ const status: Status = { } } = require(`../${PELIAS_CONFIG_FILE}`) + if (config.peliasSynonymsBase64) { + await updateStatus({ message: 'Importing synonyms', percentComplete: 10.0 }) + writeFile( + '../pelias-config/synonyms/custom_name.txt', + config.peliasSynonymsBase64.replace('data:text/plain;base64,', ''), + { encoding: 'base64' }, + function (err) { + console.log('File created') + console.log(err) + } + ) + } + await updateStatus({ message: 'Downloading GTFS feeds', percentComplete: 20.0 diff --git a/webhook/utils.ts b/webhook/utils.ts index 5df21c4..c8b4022 100644 --- a/webhook/utils.ts +++ b/webhook/utils.ts @@ -14,6 +14,7 @@ export type WebhookConfig = { deploymentId: string gtfsFeeds: Array<{ filename: string; name: string; uri: string }> logUploadUrl: string + peliasSynonymsBase64?: string resetDb: boolean workerId: string } From 4811e7467ee74411ad7b161511cba23d410e7528 Mon Sep 17 00:00:00 2001 From: miles-grant-ibigroup Date: Wed, 19 Jul 2023 12:43:39 -0400 Subject: [PATCH 2/2] refactor: address pr feedback --- webhook/processConfig.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/webhook/processConfig.ts b/webhook/processConfig.ts index 386f665..1495df5 100644 --- a/webhook/processConfig.ts +++ b/webhook/processConfig.ts @@ -93,7 +93,9 @@ const status: Status = { { encoding: 'base64' }, function (err) { console.log('File created') - console.log(err) + if (err) { + console.log(err) + } } ) }