Skip to content

Commit f8fcfb0

Browse files
Fix: correct windows
1 parent 321e7d4 commit f8fcfb0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

recipes/repl-builtin-modules/src/workflow.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import { EOL } from "node:os";
12
import { getNodeImportStatements } from "@nodejs/codemod-utils/ast-grep/import-statement";
23
import { getNodeRequireCalls } from "@nodejs/codemod-utils/ast-grep/require-call";
34
import type { SgRoot, Edit } from "@codemod.com/jssg-types/main";
45
import type Js from "@codemod.com/jssg-types/langs/javascript";
56

7+
68
/**
79
* Transform function that converts deprecated repl.builtinModules and repl._builtinLibs
810
* to module.builtinModules API.
@@ -147,7 +149,7 @@ export default function transform(root: SgRoot<Js>): string | null {
147149
const secondStatement = `const { builtinModules${aliasText} } = require(${newModule.includes('node:') ? "'node:module'" : "'module'"});`;
148150

149151
// Replace the entire variable declaration with both statements
150-
const replacementText = `${firstStatement}\n${secondStatement}`;
152+
const replacementText = `${firstStatement}${EOL}${secondStatement}`;
151153

152154
edits.push(variableDeclaration.replace(replacementText));
153155

@@ -326,7 +328,7 @@ export default function transform(root: SgRoot<Js>): string | null {
326328
edits.push({
327329
startPos: statementEnd.index,
328330
endPos: statementEnd.index,
329-
insertedText: `\n${newStatement}`
331+
insertedText: `${EOL}${newStatement}`
330332
});
331333

332334
// If original had _builtinLibs without alias, replace standalone references

0 commit comments

Comments
 (0)