@teambit/typescript 0.0.1122 → 0.0.1124
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{preview-1690773444566.js → preview-1690946168324.js} +2 -2
- package/dist/sourceFileTransformers/empty-line-encoder.js +1 -2
- package/dist/sourceFileTransformers/empty-line-encoder.js.map +1 -1
- package/dist/sourceFileTransformers/transform.js +1 -1
- package/dist/sourceFileTransformers/transform.js.map +1 -1
- package/package-tar/teambit-typescript-0.0.1124.tgz +0 -0
- package/package.json +15 -15
- package/sourceFileTransformers/empty-line-encoder.ts +1 -1
- package/sourceFileTransformers/transform.ts +1 -1
- package/package-tar/teambit-typescript-0.0.1122.tgz +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.typescript_typescript@0.0.
|
|
2
|
-
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.typescript_typescript@0.0.
|
|
1
|
+
import * as compositions_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.typescript_typescript@0.0.1124/dist/typescript.composition.js';
|
|
2
|
+
import * as overview_0 from '/home/circleci/Library/Caches/Bit/capsules/8891be5ad3d35bfc38b9cd90c0e05b598a5a55af/teambit.typescript_typescript@0.0.1124/dist/typescript.docs.mdx';
|
|
3
3
|
|
|
4
4
|
export const compositions = [compositions_0];
|
|
5
5
|
export const overview = [overview_0];
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
require("core-js/modules/es.regexp.exec.js");
|
|
5
|
-
require("core-js/modules/es.string.replace.js");
|
|
6
5
|
require("core-js/modules/es.string.trim.js");
|
|
7
6
|
Object.defineProperty(exports, "__esModule", {
|
|
8
7
|
value: true
|
|
@@ -54,7 +53,7 @@ function encodeEmptyLines(text, emptyLineMarker, newLine) {
|
|
|
54
53
|
function decodeEmptyLines(text, emptyLineMarker, newLine) {
|
|
55
54
|
const marker = toComment(emptyLineMarker || EmptyLineEncoder.defaultEmptyLineMarker);
|
|
56
55
|
const lines = text.split(/\r?\n/);
|
|
57
|
-
const uncommentedLines = lines.map(line => line.
|
|
56
|
+
const uncommentedLines = lines.map(line => line.trim() === marker ? '' : line);
|
|
58
57
|
return uncommentedLines.join(newLine || EmptyLineEncoder.defaultNewLine);
|
|
59
58
|
}
|
|
60
59
|
function addLeadingEmptyLineMarker(node, emptyLineMarker) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_typescript","data","_interopRequireDefault","require","EmptyLineEncoder","constructor","emptyLineMarker","newLine","_defineProperty2","default","defaultEmptyLineMarker","defaultNewLine","encode","text","encodeEmptyLines","decode","decodeEmptyLines","addLeadingEmptyLineMarker","node","exports","marker","toComment","lines","split","commentedLines","map","line","trim","join","uncommentedLines","
|
|
1
|
+
{"version":3,"names":["_typescript","data","_interopRequireDefault","require","EmptyLineEncoder","constructor","emptyLineMarker","newLine","_defineProperty2","default","defaultEmptyLineMarker","defaultNewLine","encode","text","encodeEmptyLines","decode","decodeEmptyLines","addLeadingEmptyLineMarker","node","exports","marker","toComment","lines","split","commentedLines","map","line","trim","join","uncommentedLines","ts","addSyntheticLeadingComment","SyntaxKind","MultiLineCommentTrivia"],"sources":["empty-line-encoder.ts"],"sourcesContent":["import ts from 'typescript';\n\nexport class EmptyLineEncoder {\n static readonly defaultEmptyLineMarker: string = '!--empty-line--!';\n static readonly defaultNewLine: string = '\\r\\n';\n constructor(emptyLineMarker?: string, newLine?: string) {\n this.emptyLineMarker = emptyLineMarker || EmptyLineEncoder.defaultEmptyLineMarker;\n this.newLine = newLine || EmptyLineEncoder.defaultNewLine;\n }\n emptyLineMarker: string;\n newLine: string;\n\n encode(text: string) {\n return encodeEmptyLines(text, this.emptyLineMarker, this.newLine);\n }\n decode(text: string) {\n return decodeEmptyLines(text, this.emptyLineMarker, this.newLine);\n }\n addLeadingEmptyLineMarker<T extends ts.Node>(node: T) {\n return addLeadingEmptyLineMarker(node, this.emptyLineMarker);\n }\n}\n\nexport function encodeEmptyLines(text: string, emptyLineMarker?: string, newLine?: string) {\n const marker = toComment(emptyLineMarker || EmptyLineEncoder.defaultEmptyLineMarker);\n\n const lines = text.split(/\\r?\\n/);\n\n const commentedLines = lines.map((line) => (line.trim() === '' ? marker : line));\n\n return commentedLines.join(newLine || EmptyLineEncoder.defaultNewLine);\n}\n\nexport function decodeEmptyLines(text: string, emptyLineMarker?: string, newLine?: string) {\n const marker = toComment(emptyLineMarker || EmptyLineEncoder.defaultEmptyLineMarker);\n\n const lines = text.split(/\\r?\\n/);\n\n const uncommentedLines = lines.map((line) => (line.trim() === marker ? '' : line));\n\n return uncommentedLines.join(newLine || EmptyLineEncoder.defaultNewLine);\n}\n\nexport function addLeadingEmptyLineMarker<T extends ts.Node>(node: T, emptyLineMarker?: string) {\n return ts.addSyntheticLeadingComment(\n node,\n ts.SyntaxKind.MultiLineCommentTrivia,\n emptyLineMarker || EmptyLineEncoder.defaultEmptyLineMarker,\n // hasTrailingNewLine\n true\n );\n}\n\nfunction toComment(marker: string) {\n return `/*${marker}*/`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,SAAAA,YAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,WAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAEO,MAAMG,gBAAgB,CAAC;EAG5BC,WAAWA,CAACC,eAAwB,EAAEC,OAAgB,EAAE;IAAA,IAAAC,gBAAA,GAAAC,OAAA;IAAA,IAAAD,gBAAA,GAAAC,OAAA;IACtD,IAAI,CAACH,eAAe,GAAGA,eAAe,IAAIF,gBAAgB,CA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AAGT,IAAI,CAACU,KAAK,CAAC,OAAO,CAAC;EAEjC,MAAMM,gBAAgB,GAAGP,KAAK,CAACG,GAAG,CAAEC,IAAI,IAAMA,IAAI,CAACC,IAAI,CAAC,CAAC,KAAKP,MAAM,GAAG,EAAE,GAAGM,IAAK,CAAC;EAElF,OAAOG,gBAAgB,CAACD,IAAI,CAACrB,OAAO,IAAIH,gBAAgB,CAACO,cAAc,CAAC;AAC1E;AAEO,SAASM,yBAAyBA,CAAoBC,IAAO,EAAEZ,eAAwB,EAAE;EAC9F,OAAOwB,qBAAE,CAACC,0BAA0B,CAClCb,IAAI,EACJY,qBAAE,CAACE,UAAU,CAACC,sBAAsB,EACpC3B,eAAe,IAAIF,gBAAgB,CAACM,sBAAsB;EAC1D;EACA,IACF,CAAC;AACH;AAEA,SAASW,SAASA,CAACD,MAAc,EAAE;EACjC,OAAQ,KAAIA,MAAO,IAAG;AACxB"}
|
|
@@ -69,7 +69,7 @@ async function transformSourceFile(sourceFilePath, sourceFileContent, transforme
|
|
|
69
69
|
const regex = new RegExp(emptyLineComment, 'g');
|
|
70
70
|
transformedSourceFileStr = transformedSourceFileStr.replace(regex, '');
|
|
71
71
|
try {
|
|
72
|
-
const formattedSourceFileStr = await (formatter === null || formatter === void 0 ? void 0 : formatter.formatSnippet(transformedSourceFileStr));
|
|
72
|
+
const formattedSourceFileStr = await (formatter === null || formatter === void 0 ? void 0 : formatter.formatSnippet(transformedSourceFileStr, sourceFilePath));
|
|
73
73
|
return formattedSourceFileStr || transformedSourceFileStr;
|
|
74
74
|
} catch (_unused) {
|
|
75
75
|
// We can ignore if the formatter fails
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_typescript","data","_interopRequireDefault","require","path","_interopRequireWildcard","_emptyLineEncoder","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","transformSourceFile","sourceFilePath","sourceFileContent","transformers","formatter","updates","ext","extname","compatibleExts","includes","transformed","entries","forEach","oldStr","newStr","oldStringRegex","RegExp","replace","encoder","EmptyLineEncoder","encode","sourceFile","ts","createSourceFile","ScriptTarget","Latest","ScriptKind","TSX","transformedResult","transform","transformedSourceFile","printer","createPrinter","removeComments","transformedSourceFileStr","printFile","decode","emptyLineComment","emptyLineMarker","regex","formattedSourceFileStr","formatSnippet","_unused"],"sources":["transform.ts"],"sourcesContent":["import { Formatter } from '@teambit/formatter';\nimport ts from 'typescript';\nimport * as path from 'path';\nimport { EmptyLineEncoder } from './empty-line-encoder';\n/**\n * Transforms a TypeScript source file using the provided transformer.\n *\n * @param sourceFilePath Path to the TypeScript source file.\n * @param sourceFileContent The content of the source file.\n * @param transformers The transformers to be applied on the source file.\n * @param formatter (Optional) An optional formatter to format the transformed code. If no formatter is provided, the function returns the transformed source file as a string without any formatting.\n * @returns A promise that resolves to the transformed source file as a string.\n */\nexport async function transformSourceFile(\n sourceFilePath: string,\n sourceFileContent: string,\n transformers: ts.TransformerFactory<ts.SourceFile>[],\n formatter?: Formatter,\n updates?: Record<string, string>\n): Promise<string> {\n const ext = path.extname(sourceFilePath);\n const compatibleExts = ['.ts', '.tsx', '.js', '.jsx'];\n if (!compatibleExts.includes(ext)) {\n if (!updates) return sourceFileContent;\n let transformed = sourceFileContent;\n Object.entries(updates).forEach(([oldStr, newStr]) => {\n const oldStringRegex = new RegExp(oldStr, 'g');\n transformed = transformed.replace(oldStringRegex, newStr);\n });\n return transformed;\n }\n\n const encoder = new EmptyLineEncoder();\n sourceFileContent = encoder.encode(sourceFileContent);\n\n const sourceFile = ts.createSourceFile(\n sourceFilePath,\n sourceFileContent,\n ts.ScriptTarget.Latest,\n true,\n ts.ScriptKind.TSX\n );\n\n const transformedResult: ts.TransformationResult<ts.SourceFile> = ts.transform<ts.SourceFile>(\n sourceFile,\n transformers\n );\n const transformedSourceFile: ts.SourceFile = transformedResult.transformed[0] as ts.SourceFile;\n\n const printer: ts.Printer = ts.createPrinter({\n removeComments: false,\n });\n\n let transformedSourceFileStr = printer.printFile(transformedSourceFile);\n transformedSourceFileStr = encoder.decode(transformedSourceFileStr);\n // Remove trailing empty line markers\n const emptyLineComment = `\\\\s*\\\\/\\\\*${encoder.emptyLineMarker}\\\\*\\\\/\\\\s*$`;\n const regex = new RegExp(emptyLineComment, 'g');\n transformedSourceFileStr = transformedSourceFileStr.replace(regex, '');\n\n try {\n const formattedSourceFileStr = await formatter?.formatSnippet(transformedSourceFileStr);\n return formattedSourceFileStr || transformedSourceFileStr;\n } catch {\n // We can ignore if the formatter fails\n // TODO: log the error\n // ignore\n }\n return transformedSourceFileStr;\n}\n"],"mappings":";;;;;;;;;;;;AACA,SAAAA,YAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,WAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,KAAA;EAAA,MAAAH,IAAA,GAAAI,uBAAA,CAAAF,OAAA;EAAAC,IAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,kBAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,iBAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAwD,SAAAM,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAH,wBAAAO,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GA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AAa,CAACP,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"names":["_typescript","data","_interopRequireDefault","require","path","_interopRequireWildcard","_emptyLineEncoder","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","transformSourceFile","sourceFilePath","sourceFileContent","transformers","formatter","updates","ext","extname","compatibleExts","includes","transformed","entries","forEach","oldStr","newStr","oldStringRegex","RegExp","replace","encoder","EmptyLineEncoder","encode","sourceFile","ts","createSourceFile","ScriptTarget","Latest","ScriptKind","TSX","transformedResult","transform","transformedSourceFile","printer","createPrinter","removeComments","transformedSourceFileStr","printFile","decode","emptyLineComment","emptyLineMarker","regex","formattedSourceFileStr","formatSnippet","_unused"],"sources":["transform.ts"],"sourcesContent":["import { Formatter } from '@teambit/formatter';\nimport ts from 'typescript';\nimport * as path from 'path';\nimport { EmptyLineEncoder } from './empty-line-encoder';\n/**\n * Transforms a TypeScript source file using the provided transformer.\n *\n * @param sourceFilePath Path to the TypeScript source file.\n * @param sourceFileContent The content of the source file.\n * @param transformers The transformers to be applied on the source file.\n * @param formatter (Optional) An optional formatter to format the transformed code. If no formatter is provided, the function returns the transformed source file as a string without any formatting.\n * @returns A promise that resolves to the transformed source file as a string.\n */\nexport async function transformSourceFile(\n sourceFilePath: string,\n sourceFileContent: string,\n transformers: ts.TransformerFactory<ts.SourceFile>[],\n formatter?: Formatter,\n updates?: Record<string, string>\n): Promise<string> {\n const ext = path.extname(sourceFilePath);\n const compatibleExts = ['.ts', '.tsx', '.js', '.jsx'];\n if (!compatibleExts.includes(ext)) {\n if (!updates) return sourceFileContent;\n let transformed = sourceFileContent;\n Object.entries(updates).forEach(([oldStr, newStr]) => {\n const oldStringRegex = new RegExp(oldStr, 'g');\n transformed = transformed.replace(oldStringRegex, newStr);\n });\n return transformed;\n }\n\n const encoder = new EmptyLineEncoder();\n sourceFileContent = encoder.encode(sourceFileContent);\n\n const sourceFile = ts.createSourceFile(\n sourceFilePath,\n sourceFileContent,\n ts.ScriptTarget.Latest,\n true,\n ts.ScriptKind.TSX\n );\n\n const transformedResult: ts.TransformationResult<ts.SourceFile> = ts.transform<ts.SourceFile>(\n sourceFile,\n transformers\n );\n const transformedSourceFile: ts.SourceFile = transformedResult.transformed[0] as ts.SourceFile;\n\n const printer: ts.Printer = ts.createPrinter({\n removeComments: false,\n });\n\n let transformedSourceFileStr = printer.printFile(transformedSourceFile);\n transformedSourceFileStr = encoder.decode(transformedSourceFileStr);\n // Remove trailing empty line markers\n const emptyLineComment = `\\\\s*\\\\/\\\\*${encoder.emptyLineMarker}\\\\*\\\\/\\\\s*$`;\n const regex = new RegExp(emptyLineComment, 'g');\n transformedSourceFileStr = transformedSourceFileStr.replace(regex, '');\n\n try {\n const formattedSourceFileStr = await formatter?.formatSnippet(transformedSourceFileStr, sourceFilePath);\n return formattedSourceFileStr || transformedSourceFileStr;\n } catch {\n // We can ignore if the formatter fails\n // TODO: log the error\n // ignore\n }\n return transformedSourceFileStr;\n}\n"],"mappings":";;;;;;;;;;;;AACA,SAAAA,YAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,WAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,KAAA;EAAA,MAAAH,IAAA,GAAAI,uBAAA,CAAAF,OAAA;EAAAC,IAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAK,kBAAA;EAAA,MAAAL,IAAA,GAAAE,OAAA;EAAAG,iBAAA,YAAAA,CAAA;IAAA,OAAAL,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAwD,SAAAM,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,O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;EAC1E,MAAMC,KAAK,GAAG,IAAIvB,MAAM,CAACqB,gBAAgB,EAAE,GAAG,CAAC;EAC/CH,wBAAwB,GAAGA,wBAAwB,CAACjB,OAAO,CAACsB,KAAK,EAAE,EAAE,CAAC;EAEtE,IAAI;IACF,MAAMC,sBAAsB,GAAG,OAAMpC,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAEqC,aAAa,CAACP,wBAAwB,EAAEjC,cAAc,CAAC;IACvG,OAAOuC,sBAAsB,IAAIN,wBAAwB;EAC3D,CAAC,CAAC,OAAAQ,OAAA,EAAM;IACN;IACA;IACA;EAAA;EAEF,OAAOR,wBAAwB;AACjC"}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/typescript",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.1124",
|
|
4
4
|
"homepage": "https://bit.cloud/teambit/typescript/typescript",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.typescript",
|
|
8
8
|
"name": "typescript",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.1124"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"lodash": "4.17.21",
|
|
@@ -20,25 +20,25 @@
|
|
|
20
20
|
"core-js": "^3.0.0",
|
|
21
21
|
"@babel/runtime": "7.20.0",
|
|
22
22
|
"@teambit/harmony": "0.4.6",
|
|
23
|
-
"@teambit/compiler": "0.0.
|
|
23
|
+
"@teambit/compiler": "0.0.1124",
|
|
24
24
|
"@teambit/typescript.modules.ts-config-mutator": "0.0.76",
|
|
25
|
-
"@teambit/builder": "0.0.
|
|
26
|
-
"@teambit/isolator": "0.0.
|
|
27
|
-
"@teambit/component": "0.0.
|
|
28
|
-
"@teambit/dependency-resolver": "0.0.
|
|
29
|
-
"@teambit/formatter": "0.0.
|
|
25
|
+
"@teambit/builder": "0.0.1124",
|
|
26
|
+
"@teambit/isolator": "0.0.1124",
|
|
27
|
+
"@teambit/component": "0.0.1124",
|
|
28
|
+
"@teambit/dependency-resolver": "0.0.1124",
|
|
29
|
+
"@teambit/formatter": "0.0.675",
|
|
30
30
|
"@teambit/semantics.entities.semantic-schema": "0.0.53",
|
|
31
31
|
"@teambit/ts-server": "0.0.48",
|
|
32
|
-
"@teambit/aspect-loader": "0.0.
|
|
33
|
-
"@teambit/envs": "0.0.
|
|
32
|
+
"@teambit/aspect-loader": "0.0.1124",
|
|
33
|
+
"@teambit/envs": "0.0.1124",
|
|
34
34
|
"@teambit/logger": "0.0.845",
|
|
35
|
-
"@teambit/workspace": "0.0.
|
|
35
|
+
"@teambit/workspace": "0.0.1124",
|
|
36
36
|
"@teambit/bit-error": "0.0.402",
|
|
37
|
-
"@teambit/schema": "0.0.
|
|
38
|
-
"@teambit/scope": "0.0.
|
|
37
|
+
"@teambit/schema": "0.0.1124",
|
|
38
|
+
"@teambit/scope": "0.0.1124",
|
|
39
39
|
"@teambit/cli": "0.0.752",
|
|
40
|
-
"@teambit/pkg": "0.0.
|
|
41
|
-
"@teambit/watcher": "0.0.
|
|
40
|
+
"@teambit/pkg": "0.0.1124",
|
|
41
|
+
"@teambit/watcher": "0.0.136"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/lodash": "4.14.165",
|
|
@@ -36,7 +36,7 @@ export function decodeEmptyLines(text: string, emptyLineMarker?: string, newLine
|
|
|
36
36
|
|
|
37
37
|
const lines = text.split(/\r?\n/);
|
|
38
38
|
|
|
39
|
-
const uncommentedLines = lines.map((line) => (line.
|
|
39
|
+
const uncommentedLines = lines.map((line) => (line.trim() === marker ? '' : line));
|
|
40
40
|
|
|
41
41
|
return uncommentedLines.join(newLine || EmptyLineEncoder.defaultNewLine);
|
|
42
42
|
}
|
|
@@ -59,7 +59,7 @@ export async function transformSourceFile(
|
|
|
59
59
|
transformedSourceFileStr = transformedSourceFileStr.replace(regex, '');
|
|
60
60
|
|
|
61
61
|
try {
|
|
62
|
-
const formattedSourceFileStr = await formatter?.formatSnippet(transformedSourceFileStr);
|
|
62
|
+
const formattedSourceFileStr = await formatter?.formatSnippet(transformedSourceFileStr, sourceFilePath);
|
|
63
63
|
return formattedSourceFileStr || transformedSourceFileStr;
|
|
64
64
|
} catch {
|
|
65
65
|
// We can ignore if the formatter fails
|
|
Binary file
|