Skip to content

Commit c1b80cb

Browse files
author
David Hasani
committed
fix: handle CRLF chars
1 parent 8e0cf7f commit c1b80cb

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

packages/core/src/codewhisperer/commands/startTransformByQ.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,14 @@ async function setBuildSystemCommand() {
108108
transformByQState.getBuildSystem() === BuildSystem.Maven ? 'mvn' : 'gradle'
109109
)
110110
}
111+
const gradlewPath = path.join(transformByQState.getProjectPath(), 'gradlew')
112+
if (fs.existsSync(gradlewPath)) {
113+
// TO-DO: maybe do this for mvnw too OR handle this in backend?
114+
// replace Windows CRLF characters with LF characters so that our backend build can run
115+
const wrapperData = fs.readFileSync(gradlewPath).toString()
116+
const newWrapperData = wrapperData.replace(/\r\n/g, '\n')
117+
fs.writeFileSync(gradlewPath, newWrapperData)
118+
}
111119
getLogger().info(`CodeTransformation: set build system command to ${transformByQState.getBuildSystemCommand()}`)
112120
}
113121

packages/core/src/codewhisperer/models/model.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ export enum JDKVersion {
310310

311311
export enum BuildSystem {
312312
Maven = 'Maven',
313-
Gradle = 'Gradle',
313+
Gradle = 'GRADLE', // needs to be all caps for backend; TO-DO: fix this by using equalsIgnoreCase in backend
314314
Unknown = 'Unknown',
315315
}
316316

0 commit comments

Comments
 (0)