Skip to content

Commit b254d39

Browse files
Fixed relative path calculation (#20)
1 parent e957281 commit b254d39

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ const getCircularReplacer = () => {
368368
* Write AST data to a json file
369369
*/
370370
const writeAstFile = (file, ast, options) => {
371-
const relativePath = file.replace(new RegExp("^" + options.src + "/"), "");
371+
const relativePath = path.relative(options.src, file)
372372
const outAstFile = path.join(options.output, relativePath + ".json");
373373
const data = {
374374
fullName: file,
@@ -384,7 +384,7 @@ const writeAstFile = (file, ast, options) => {
384384
};
385385

386386
const writeTypesFile = (file, seenTypes, options) => {
387-
const relativePath = file.replace(new RegExp("^" + options.src + "/"), "");
387+
const relativePath = path.relative(options.src, file)
388388
const outTypeFile = path.join(options.output, relativePath + ".typemap");
389389
fs.mkdirSync(path.dirname(outTypeFile), {recursive: true});
390390
fs.writeFileSync(

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@joernio/astgen",
3-
"version": "3.16.0",
3+
"version": "3.17.0",
44
"description": "Generate JS/TS AST in json format with Babel",
55
"exports": "./index.js",
66
"keywords": [

0 commit comments

Comments
 (0)