* Transpile lua scripts in one file, specifying an specific directory to be saved * @param pathname - the path to the directory containing the scripts * @param writeDir - the path to the directory where scripts will be saved
(pathname: string, writeDir: string)
| 12 | * @param writeDir - the path to the directory where scripts will be saved |
| 13 | */ |
| 14 | async transpileScripts(pathname: string, writeDir: string): Promise<void> { |
| 15 | const writeFilenamePath = path.normalize(writeDir); |
| 16 | |
| 17 | if (!fs.existsSync(writeFilenamePath)) { |
| 18 | fs.mkdirSync(writeFilenamePath); |
| 19 | } |
| 20 | |
| 21 | const paths = new Set<string>(); |
| 22 | if (!paths.has(pathname)) { |
| 23 | paths.add(pathname); |
| 24 | const scripts = await this.loadScripts(pathname); |
| 25 | for (const command of scripts) { |
| 26 | const { |
| 27 | name, |
| 28 | options: { numberOfKeys, lua }, |
| 29 | } = command; |
| 30 | await writeFile( |
| 31 | path.join(writeFilenamePath, `${name}-${numberOfKeys}.lua`), |
| 32 | lua, |
| 33 | ); |
| 34 | } |
| 35 | } |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | const scriptLoader = new RawScriptLoader(); |
no test coverage detected