Skip to content

Commit 674eced

Browse files
committed
[DXDOCS-129] fix: keep block comments
1 parent 7f421fa commit 674eced

File tree

2 files changed

+4
-15
lines changed

2 files changed

+4
-15
lines changed

codemods/clean-redirects-config.js

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const prettyPrint = require("./common/pretty-print");
22

3-
const OBJECT_COMMENT_REGEX = /\, \/\//g;
3+
const OBJECT_COMMENT_REGEX = /\} (\/\*[^\/\*]+\*\/)\,/g;
44

55
/**
66
* clean up redirects that point to some other redirect and merge the 'from' field value
@@ -43,8 +43,7 @@ module.exports = function(fileInfo, api) {
4343
j(toConfigNodePath).remove();
4444
}
4545
});
46-
let transformedSource = prettyPrint(root);
47-
// keep spaces for comments within an object
48-
transformedSource = transformedSource.replace(OBJECT_COMMENT_REGEX, ',\n\n\t//');
49-
return transformedSource;
46+
const transformedSource = prettyPrint(root);
47+
// keep position and spaces for block comments within the redirect object
48+
return transformedSource.replace(OBJECT_COMMENT_REGEX, (match, group) => `},\n\n\t${group}`);
5049
}

codemods/common/replace-block-comments.js

-10
This file was deleted.

0 commit comments

Comments
 (0)