@@ -44,6 +44,8 @@ import {
44
44
echo ,
45
45
makeDirectory ,
46
46
readFile ,
47
+ renameFile ,
48
+ writeFile ,
47
49
} from "isaacscript-common-node" ;
48
50
import {
49
51
assertDefined ,
@@ -169,7 +171,7 @@ See the [ModCallbackCustom](/isaacscript-common/other/enums/ModCallbackCustom) e
169
171
`
170
172
. trim ( )
171
173
. concat ( "\n" ) ;
172
- fs . writeFileSync ( filePath , fileContent ) ;
174
+ writeFile ( filePath , fileContent ) ;
173
175
}
174
176
175
177
/** Move the files in the "modules" directory to proper directories. */
@@ -201,7 +203,7 @@ function moveModulesFiles() {
201
203
const dstDirectory = path . join ( PACKAGE_DOCS_DIR , directoryName ) ;
202
204
makeDirectory ( dstDirectory ) ;
203
205
const dstPath = path . join ( dstDirectory , newFileName ) ;
204
- fs . renameSync ( markdownFilePath , dstPath ) ;
206
+ renameFile ( markdownFilePath , dstPath ) ;
205
207
206
208
if ( DEBUG ) {
207
209
echo ( `Moved:\n ${ markdownFilePath } \n -->\n ${ dstPath } ` ) ;
@@ -244,7 +246,7 @@ function moveDirsToOther() {
244
246
for ( const otherDirName of OTHER_DIR_NAMES ) {
245
247
const srcPath = path . join ( PACKAGE_DOCS_DIR , otherDirName ) ;
246
248
const dstPath = path . join ( OTHER_DIR , otherDirName ) ;
247
- fs . renameSync ( srcPath , dstPath ) ;
249
+ renameFile ( srcPath , dstPath ) ;
248
250
}
249
251
}
250
252
@@ -260,7 +262,7 @@ function addCategoryFile(directoryPath: string) {
260
262
if ( position !== undefined ) {
261
263
fileContents += `position: ${ position } \n` ;
262
264
}
263
- fs . writeFileSync ( categoryFilePath , fileContents ) ;
265
+ writeFile ( categoryFilePath , fileContents ) ;
264
266
}
265
267
266
268
function addMarkdownHeader ( filePath : string , directoryName : string ) {
@@ -292,7 +294,7 @@ custom_edit_url: null
292
294
fileContents = lines . join ( "\n" ) ;
293
295
294
296
const newFileContents = header + fileContents ;
295
- fs . writeFileSync ( filePath , newFileContents ) ;
297
+ writeFile ( filePath , newFileContents ) ;
296
298
}
297
299
298
300
function getTitle ( filePath : string , directoryName : string ) {
@@ -345,14 +347,14 @@ function renameSpecialPages() {
345
347
"features_other_extraConsoleCommands_commands.md" ,
346
348
) ;
347
349
const newPath = path . join ( FEATURES_DIR , "ExtraConsoleCommandsList.md" ) ;
348
- fs . renameSync ( oldPath , newPath ) ;
350
+ renameFile ( oldPath , newPath ) ;
349
351
350
352
const contents = readFile ( newPath ) ;
351
353
const newContents = contents . replace (
352
354
"# features_other_extraConsoleCommands_commands" ,
353
355
"# Extra Console Commands (List)" ,
354
356
) ;
355
- fs . writeFileSync ( newPath , newContents ) ;
357
+ writeFile ( newPath , newContents ) ;
356
358
}
357
359
358
360
function deleteDuplicatedPages ( ) {
@@ -412,7 +414,7 @@ function renameDuplicatedPages() {
412
414
properPath = path . join ( FEATURES_DIR , properName ) ;
413
415
}
414
416
415
- fs . renameSync ( filePath , properPath ) ;
417
+ renameFile ( filePath , properPath ) ;
416
418
417
419
if ( DEBUG ) {
418
420
echo ( `Renamed:\n ${ filePath } \n -->\n ${ properPath } ` ) ;
@@ -433,7 +435,8 @@ function fixLinks() {
433
435
const markdownFilePaths = globSync ( "**/*.md" , { cwd : PACKAGE_DOCS_DIR } ) ;
434
436
435
437
for ( const filePath of markdownFilePaths ) {
436
- const fileContents = readFile ( filePath ) ;
438
+ const fullFilePath = path . join ( PACKAGE_DOCS_DIR , filePath ) ;
439
+ const fileContents = readFile ( fullFilePath ) ;
437
440
let newFileContents = fileContents ;
438
441
439
442
// Start by removing any links with a "modules" prefix, since they are moved to the root.
@@ -472,7 +475,8 @@ function fixLinks() {
472
475
newFileContents = newFileContents . replaceAll ( brokenLink , fixedLink ) ;
473
476
}
474
477
475
- const numDirectoriesAwayFromRoot = getNumDirectoriesAwayFromRoot ( filePath ) ;
478
+ const numDirectoriesAwayFromRoot =
479
+ getNumDirectoriesAwayFromRoot ( fullFilePath ) ;
476
480
const linkPrefix = "../" . repeat ( numDirectoriesAwayFromRoot ) ;
477
481
478
482
for ( const brokenLinkDirName of BROKEN_LINK_DIR_NAMES ) {
@@ -496,7 +500,7 @@ function fixLinks() {
496
500
newFileContents = newFileContents . replaceAll ( / t y p e s _ \w + \. / gm, "" ) ;
497
501
498
502
if ( fileContents !== newFileContents ) {
499
- fs . writeFileSync ( filePath , newFileContents ) ;
503
+ writeFile ( fullFilePath , newFileContents ) ;
500
504
}
501
505
}
502
506
}
0 commit comments