Add luaLibDir compiler option and in operator, fix template strings#60
Conversation
src/Compiler.ts
Outdated
| var argv = minimist(args, { | ||
| const argv = minimist(args, { | ||
| string: ['l'], | ||
| alias: { h: 'help', v: 'version', l: 'luaTarget' }, |
There was a problem hiding this comment.
Add CLI options for addHeader and lualiboutdir. Don't forget to update help text and readme.
src/Compiler.ts
Outdated
| options.luaLibDir = path.join(options.outDir, options.luaLibDir); | ||
| } | ||
| if (!fs.existsSync(options.luaLibDir)){ | ||
| fs.mkdirSync(options.luaLibDir); |
There was a problem hiding this comment.
Pretty sure mkdir sync is not recursive. In this case this will error on a longer path.
There was a problem hiding this comment.
Typescript has a function to recursively create files / directories. not sure If that function is exposed tho.
src/Compiler.ts
Outdated
| options.luaLibDir = options.outDir; | ||
| } | ||
| else { | ||
| options.luaLibDir = path.join(options.outDir, options.luaLibDir); |
There was a problem hiding this comment.
should be path.resolve, just to be sure.
| interface CompilerOptions extends ts.CompilerOptions { | ||
| addHeader?: boolean; | ||
| luaLibDir?: string; | ||
| } |
src/Compiler.ts
Outdated
| // Copy lualib to target dir | ||
| // This isnt run in sync because copyFileSync wont report errors. | ||
| fs.copyFile(path.resolve(__dirname, "../dist/lualib/typescript.lua"), path.join(options.outDir, "typescript_lualib.lua"), (err: NodeJS.ErrnoException) => { | ||
| fs.copyFile(path.resolve(__dirname, "../dist/lualib/typescript.lua"), path.join(options.luaLibDir, "typescript_lualib.lua"), (err: NodeJS.ErrnoException) => { |
There was a problem hiding this comment.
When you change options.luaLibDir the require call should be resolved, in order to point to that new path, https://github.com/Perryvw/TypescriptToLua/blob/master/src/Transpiler.ts#L36
There was a problem hiding this comment.
See comment below.
| process.exit(1); | ||
| if (invalidErrorCount != commandLine.errors.length) { | ||
| process.exit(1); | ||
| } |
There was a problem hiding this comment.
all of logError looks pretty dodgy. Improve or add some comments that explain what/why this function does.
|
Not sure if we want to support luaLibDir in the first place, sounds like a lot of hacky stuff for little gain. |
|
After some discussion we decided not to want the lualibdir stuff in the main branch. Like I said in the previous comment it seems like asking for trouble with limited pay-off. The rest of the pull request looks good and I'd be happy to merge if you remove the lualibdir part. |
|
luaLibDir solves the problem of a directory structure like this: There is no additional resolving needed. It can only be used to specify the correct subfolder, nothing else. |
|
Did you try setting rootDir to |
|
rootDir solves the problem, so I removed luaLibDir. It was broken on Windows but is fixed now. I can't tell if it works on other platforms tho. |
|
There should tests for compiling different types of skeleton projects. I might make them at some point but I've never done that so some examples would be very helpful. |
luaLibDiris a new compiler option that specifies the save location fortypescript_lualib.luarelative tooutDir.Typescript template strings now cast all expressions to string.