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