From 6072f5c8531028f3ee75acea3f2c74e75c67f646 Mon Sep 17 00:00:00 2001 From: rofe Date: Wed, 8 Nov 2023 14:13:41 +0100 Subject: [PATCH] fix: monitor script update failing --- src/newrelic/synthetics.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/newrelic/synthetics.js b/src/newrelic/synthetics.js index b26053c..d785164 100644 --- a/src/newrelic/synthetics.js +++ b/src/newrelic/synthetics.js @@ -11,7 +11,7 @@ */ import { h1 } from '@adobe/fetch'; import fs from 'fs'; -import path from 'path'; +import { fileURLToPath } from 'url'; const { fetch } = h1(); export const MONITOR_FREQUENCY = 15; @@ -105,8 +105,9 @@ async function updateMonitor(auth, monitor, url, script, locations, frequency) { console.log('Updating script for monitor', monitor.name); + const defaultScript = fileURLToPath(new URL('./monitor_script.js', import.meta.url)); const scriptText = Buffer.from(fs - .readFileSync(script || path.resolve(__rootdir, 'src', 'newrelic', 'monitor_script.js')) + .readFileSync(script || defaultScript) .toString() .replace('$$$URL$$$', url) .replace('$$$NS$$$', getNS(url)))