File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed
recipes/repl-builtin-modules/src Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change
1
+ import { EOL } from "node:os" ;
1
2
import { getNodeImportStatements } from "@nodejs/codemod-utils/ast-grep/import-statement" ;
2
3
import { getNodeRequireCalls } from "@nodejs/codemod-utils/ast-grep/require-call" ;
3
4
import type { SgRoot , Edit } from "@codemod.com/jssg-types/main" ;
4
5
import type Js from "@codemod.com/jssg-types/langs/javascript" ;
5
6
7
+
6
8
/**
7
9
* Transform function that converts deprecated repl.builtinModules and repl._builtinLibs
8
10
* to module.builtinModules API.
@@ -147,7 +149,7 @@ export default function transform(root: SgRoot<Js>): string | null {
147
149
const secondStatement = `const { builtinModules${ aliasText } } = require(${ newModule . includes ( 'node:' ) ? "'node:module'" : "'module'" } );` ;
148
150
149
151
// Replace the entire variable declaration with both statements
150
- const replacementText = `${ firstStatement } \n ${ secondStatement } ` ;
152
+ const replacementText = `${ firstStatement } ${ EOL } ${ secondStatement } ` ;
151
153
152
154
edits . push ( variableDeclaration . replace ( replacementText ) ) ;
153
155
@@ -326,7 +328,7 @@ export default function transform(root: SgRoot<Js>): string | null {
326
328
edits . push ( {
327
329
startPos : statementEnd . index ,
328
330
endPos : statementEnd . index ,
329
- insertedText : `\n ${ newStatement } `
331
+ insertedText : `${ EOL } ${ newStatement } `
330
332
} ) ;
331
333
332
334
// If original had _builtinLibs without alias, replace standalone references
You can’t perform that action at this time.
0 commit comments