From b254d3991fdc17fa6db88914abdcf18e678aea23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20Leuth=C3=A4user?= <1417198+max-leuthaeuser@users.noreply.github.com> Date: Wed, 13 Nov 2024 14:21:27 +0100 Subject: [PATCH] Fixed relative path calculation (#20) --- index.js | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index c52446f..9146603 100644 --- a/index.js +++ b/index.js @@ -368,7 +368,7 @@ const getCircularReplacer = () => { * Write AST data to a json file */ const writeAstFile = (file, ast, options) => { - const relativePath = file.replace(new RegExp("^" + options.src + "/"), ""); + const relativePath = path.relative(options.src, file) const outAstFile = path.join(options.output, relativePath + ".json"); const data = { fullName: file, @@ -384,7 +384,7 @@ const writeAstFile = (file, ast, options) => { }; const writeTypesFile = (file, seenTypes, options) => { - const relativePath = file.replace(new RegExp("^" + options.src + "/"), ""); + const relativePath = path.relative(options.src, file) const outTypeFile = path.join(options.output, relativePath + ".typemap"); fs.mkdirSync(path.dirname(outTypeFile), {recursive: true}); fs.writeFileSync( diff --git a/package.json b/package.json index 3bb6d4e..0bea23e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@joernio/astgen", - "version": "3.16.0", + "version": "3.17.0", "description": "Generate JS/TS AST in json format with Babel", "exports": "./index.js", "keywords": [