@@ -7,15 +7,13 @@ import * as yargs from 'yargs'
77
88// ES6 syntax broken
99import dedent = require ( "dedent" )
10- import mkdirp = require ( "mkdirp" )
1110
1211import { LuaTranspiler , TranspileError } from "./Transpiler" ;
1312import { TSHelper as tsEx } from "./TSHelper" ;
1413
1514interface CompilerOptions extends ts . CompilerOptions {
1615 addHeader ? : boolean ;
17- luaTarget ? : string
18- luaLibDir ? : string ;
16+ luaTarget ? : string ;
1917}
2018
2119function compile ( fileNames : string [ ] , options : CompilerOptions ) : void {
@@ -49,17 +47,6 @@ function compile(fileNames: string[], options: CompilerOptions): void {
4947 options . outDir = options . rootDir ;
5048 }
5149
52- options . luaLibDir = path . resolve ( options . outDir , options . luaLibDir ) ;
53- mkdirp . sync ( options . luaLibDir ) ;
54-
55- // Copy lualib to target dir
56- // This isnt run in sync because copyFileSync wont report errors.
57- fs . copyFile ( path . resolve ( __dirname , "../dist/lualib/typescript.lua" ) , path . join ( options . luaLibDir , "typescript_lualib.lua" ) , ( err : NodeJS . ErrnoException ) => {
58- if ( err ) {
59- console . log ( "ERROR: copying lualib to output." ) ;
60- }
61- } ) ;
62-
6350 program . getSourceFiles ( ) . forEach ( sourceFile => {
6451 if ( ! sourceFile . isDeclarationFile ) {
6552 try {
@@ -70,7 +57,8 @@ function compile(fileNames: string[], options: CompilerOptions): void {
7057
7158 let outPath = sourceFile . fileName ;
7259 if ( options . outDir !== options . rootDir ) {
73- outPath = path . join ( options . outDir , path . resolve ( sourceFile . fileName ) . replace ( rootDir , "" ) ) ;
60+ const relativeSourcePath = path . resolve ( sourceFile . fileName ) . replace ( path . resolve ( rootDir ) , "" ) ;
61+ outPath = path . join ( options . outDir , relativeSourcePath ) ;
7462 }
7563
7664 // change extension
@@ -94,7 +82,17 @@ function compile(fileNames: string[], options: CompilerOptions): void {
9482 }
9583 } ) ;
9684
97- process . exit ( 0 ) ;
85+ // Copy lualib to target dir
86+ // This isnt run in sync because copyFileSync wont report errors.
87+ fs . copyFile ( path . resolve ( __dirname , "../dist/lualib/typescript.lua" ) , path . join ( options . outDir , "typescript_lualib.lua" ) , ( err : NodeJS . ErrnoException ) => {
88+ if ( err ) {
89+ console . log ( "ERROR: copying lualib to output." ) ;
90+ process . exit ( 1 ) ;
91+ }
92+ else {
93+ process . exit ( 0 ) ;
94+ }
95+ } ) ;
9896}
9997
10098function printAST ( node : ts . Node , indent : number ) {
@@ -139,12 +137,6 @@ function executeCommandLine(args: ReadonlyArray<string>) {
139137 describe : 'Specify Lua target version.' ,
140138 type : 'string'
141139 } ,
142- 'lld' : {
143- alias : 'luaLibDir' ,
144- describe : 'Specify typescript_lualib.lua location relative to outDir.' ,
145- default : './' ,
146- type : 'string'
147- } ,
148140 'ah' : {
149141 alias : 'addHeader' ,
150142 describe : 'Specify if a header will be added to compiled files.' ,
0 commit comments