Skip to content

Commit dc3c427

Browse files
author
Alex D
committed
added npm package
1 parent adcb8ab commit dc3c427

File tree

9 files changed

+187
-3
lines changed

9 files changed

+187
-3
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@ package-lock.json
1515
__build
1616
/thirdparty/glew-2.2.0/build/vc15/tmp
1717
/thirdparty/glew-2.2.0/bin
18-
/thirdparty/glew-2.2.0/lib
18+
/thirdparty/glew-2.2.0/lib
19+
/packages/tsc-lua/lib
20+
/packages/tsc-lua/node_modules

README.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,12 @@ class Employee extends Person {
119119
let howard = new Employee("Howard", "Sales");
120120
console.log(howard.ElevatorPitch);
121121
```
122-
3) Run it.
122+
123+
```
124+
node __out/main.js test.ts
125+
```
126+
127+
4) Run it.
123128

124129
```
125130
lua -e "require('./JS')" test.lua

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"watch": "tsc -w -p ./",
1818
"lint": "tslint src/**/*.ts -t verbose",
1919
"build": "tsc -p tsconfig.json",
20-
"exec": "ts-node src/main.ts"
20+
"exec": "ts-node src/main.ts",
21+
"prepublish": "prepublish_npm.cmd"
2122
},
2223
"bin": {
2324
"tsc-lua": "./__out/main.js"

packages/tsc-lua/JS.lua

24.1 KB
Binary file not shown.

packages/tsc-lua/JS.lua.map

+1
Original file line numberDiff line numberDiff line change

packages/tsc-lua/README.md

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
TypeScript for Lua
2+
===========================
3+
4+
License
5+
-------
6+
7+
TypeScriptLua is licensed under the MIT license.
8+
9+
Quick Start
10+
-----------
11+
12+
0) install
13+
14+
```
15+
node -i typescript-lua-compiler
16+
```
17+
18+
19+
1) Compile test.ts
20+
21+
create file test.ts
22+
23+
```TypeScript
24+
declare var print: any;
25+
26+
class Person {
27+
protected name: string;
28+
constructor(name: string) { this.name = name; }
29+
}
30+
31+
class Employee extends Person {
32+
private department: string;
33+
34+
constructor(name: string, department: string) {
35+
super(name);
36+
this.department = department;
37+
}
38+
39+
public get ElevatorPitch() {
40+
return `Hello, my name is ${this.name} and I work in ${this.department}.`;
41+
}
42+
}
43+
44+
let howard = new Employee("Howard", "Sales");
45+
print(howard.ElevatorPitch);
46+
```
47+
48+
```
49+
tsc-lua test.ts
50+
```
51+
52+
Now you have test.lua
53+
54+
2) Run it.
55+
56+
```
57+
lua test.lua
58+
```
59+
60+
Result:
61+
```
62+
Hello, my name is Howard and I work in Sales.
63+
```
64+
65+
Enjoy it.
66+
67+
How to use JavaScript Library
68+
-----------
69+
70+
1) Copy JS.lua into your folder where you run the compiled app.
71+
72+
2) Compile test.ts
73+
74+
create file test.ts
75+
76+
```TypeScript
77+
class Person {
78+
protected name: string;
79+
constructor(name: string) { this.name = name; }
80+
}
81+
82+
class Employee extends Person {
83+
private department: string;
84+
85+
constructor(name: string, department: string) {
86+
super(name);
87+
this.department = department;
88+
}
89+
90+
public get ElevatorPitch() {
91+
return `Hello, my name is ${this.name} and I work in ${this.department}.`;
92+
}
93+
}
94+
95+
let howard = new Employee("Howard", "Sales");
96+
console.log(howard.ElevatorPitch);
97+
```
98+
99+
```
100+
tsc-lua test.ts
101+
```
102+
103+
```
104+
3) Run it.
105+
106+
```
107+
lua -e "require('./JS')" test.lua
108+
```
109+
110+
Result:
111+
```
112+
Hello, my name is Howard and I work in Sales.
113+
```
114+
115+
Enjoy it

packages/tsc-lua/bin/tsc-lua

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env node
2+
require('../lib/main.js')

packages/tsc-lua/package.json

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"name": "typescript-lua-compiler",
3+
"version": "1.0.4",
4+
"description": "TypeScript compiler for Lua",
5+
"keywords": [
6+
"typescript",
7+
"lua",
8+
"tsc-lua",
9+
"compiler"
10+
],
11+
"main": "main.js",
12+
"scripts": {
13+
"test": "echo \"Error: no test specified\" && exit 1"
14+
},
15+
"bin": {
16+
"tsc-lua": "./bin/tsc-lua"
17+
},
18+
"dependencies": {
19+
"cross-spawn": "^6.0.5",
20+
"fs-extra": "^7.0.1",
21+
"path": "^0.12.7",
22+
"source-map": "^0.7.3",
23+
"typescript": "^3.2.2"
24+
},
25+
"engines": {
26+
"node": ">=4.2.0"
27+
},
28+
"files": [
29+
"bin/",
30+
"lib/",
31+
"JS.lua",
32+
"JS.lua.map",
33+
"README.md"
34+
],
35+
"author": "Alexander Duzhar",
36+
"license": "ISC",
37+
"bugs": {
38+
"url": "https://github.com/ashleygwilliams/my_package/issues"
39+
},
40+
"homepage": "https://github.com/ASDAlexander77/TypeScriptLUA/#readme"
41+
}

prepublish_npm.cmd

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
del "packages\tsc-lua\lib\*.js"
2+
del "packages\tsc-lua\lib\*.js.map"
3+
4+
del "packages\tsc-lua\*.lua"
5+
del "packages\tsc-lua\*.lua.map"
6+
7+
@call tsc -p ./
8+
copy __out\*.js "packages\tsc-lua\lib"
9+
copy __out\*.js.map "packages\tsc-lua\lib"
10+
11+
cd experiments\jslib
12+
node ../../__out/main.js -singleModule
13+
14+
copy *.lua "..\..\packages\tsc-lua\"
15+
copy *.lua.map "..\..\packages\tsc-lua\"
16+
17+
cd ..\..

0 commit comments

Comments
 (0)