From 6368707541ecb66c3b9acfce9657909a17e46a06 Mon Sep 17 00:00:00 2001 From: yname Date: Thu, 26 Dec 2024 14:38:09 -0500 Subject: [PATCH] Make paths in resulting sourcemap absolute --- src/index.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index 09f379b..3cca604 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,5 @@ import fs from 'fs' +import { resolve } from 'path' import { spawn } from 'child_process' // These are where I (yname) have my Rojo projects. @@ -43,23 +44,23 @@ function getSourcemap(root: string): Promise { }) } -function prefixSourcemap( +function absoluteSourcemap( sourcemap: RojoSourcemap, prefix: string, ): RojoSourcemap { return { name: sourcemap.name, className: sourcemap.className, - filePaths: sourcemap.filePaths?.map((path) => `${prefix}/${path}`), + filePaths: sourcemap.filePaths?.map((path) => resolve(`${prefix}/${path}`)), children: sourcemap.children?.map((child) => - prefixSourcemap(child, prefix), + absoluteSourcemap(child, prefix), ), } } async function getPrefixedSourcemap(root: string): Promise { const sourcemap = await getSourcemap(root) - const prefixed = prefixSourcemap(sourcemap, root) + const prefixed = absoluteSourcemap(sourcemap, root) return prefixed }