1
1
import { join , dirname } from 'path'
2
- import fs from 'fs-extra'
3
2
import { fileURLToPath } from 'url'
4
3
import { readCsv } from '../../lib/csv.mjs'
5
4
import { parseOpcode , formatOpcode } from '../../lib/opcode.mjs'
5
+ import { mkdirSync , readFileSync , writeFileSync } from 'fs'
6
6
7
7
const __dirname = fileURLToPath ( new URL ( '.' , import . meta. url ) )
8
8
@@ -14,7 +14,7 @@ if (/^\d\.\d$/.test(version)) {
14
14
15
15
const csvVersion = version . replace ( / 0 + $ / , '' )
16
16
17
- const text = fs . readFileSync ( join ( __dirname , '../../cn-opcodes.csv' ) , 'utf-8' )
17
+ const text = readFileSync ( join ( __dirname , '../../cn-opcodes.csv' ) , 'utf-8' )
18
18
const table = readCsv ( text , null , { header : 0 , skip : 1 } )
19
19
20
20
const output = { }
@@ -65,32 +65,32 @@ const tab = ` `
65
65
const opcodeFile = join ( workspace , 'FFXIVOpcodes/Ipcs_cn.cs' )
66
66
const constantFile = join ( workspace , 'FFXIVConstants/CN.cs' )
67
67
68
- fs . mkdirpSync ( dirname ( opcodeFile ) )
69
- fs . mkdirpSync ( dirname ( constantFile ) )
68
+ mkdirSync ( dirname ( opcodeFile ) , { recursive : true } )
69
+ mkdirSync ( dirname ( constantFile ) , { recursive : true } )
70
70
71
- fs . writeFileSync (
71
+ writeFileSync (
72
72
opcodeFile ,
73
73
`// Generated by https://github.com/zhyupe/ffxiv-opcode-worker
74
74
75
75
namespace FFXIVOpcodes.CN
76
76
{
77
77
${ scopes
78
- . map (
79
- ( key ) => `${ tab } public enum ${ key } Type : ushort
78
+ . map (
79
+ ( key ) => `${ tab } public enum ${ key } Type : ushort
80
80
${ tab } {
81
81
${ ( output [ key ] || [ ] )
82
- . sort ( ( a , b ) => a . name . localeCompare ( b . name ) )
83
- . map ( ( { name, opcode } ) => `${ tab } ${ tab } ${ name } = ${ opcode } ,` )
84
- . join ( '\n' ) }
82
+ . sort ( ( a , b ) => a . name . localeCompare ( b . name ) )
83
+ . map ( ( { name, opcode } ) => `${ tab } ${ tab } ${ name } = ${ opcode } ,` )
84
+ . join ( '\n' ) }
85
85
${ tab } };`
86
- )
87
- . join ( '\n\n' ) }
86
+ )
87
+ . join ( '\n\n' ) }
88
88
}
89
89
`
90
90
)
91
91
92
92
const offset = parseOpcode ( specialValues . InventoryHandlerOffset ) + 7
93
- fs . writeFileSync (
93
+ writeFileSync (
94
94
constantFile ,
95
95
`// Generated by https://github.com/zhyupe/ffxiv-opcode-worker
96
96
using System.Collections.Generic;
0 commit comments