forked from gkz/LiveScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.ls
More file actions
74 lines (58 loc) · 2.04 KB
/
cli.ls
File metadata and controls
74 lines (58 loc) · 2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
require! path: {normalize}
# version
command-eq '-v', ["LiveScript version #{LiveScript.VERSION}"]
# eval print
command-eq '-pe "2 + 2"', [4]
# help
command-eq '-h', [/^Usage: lsc (.|\n)*Misc:(.|\n)*Output control:(.|\n)*Version/]
one-js = 'var f;\nf = function(x){\n return 1 + x;\n};'
one-path-js = normalize 'test/data/one.js'
one-path-ls = normalize 'test/data/one.ls'
# compile print
command-eq '-cpb --no-header test/data/one.ls', [one-js]
# compile
command-eq '-cb --no-header --debug test/data/one.ls', ["#one-path-ls => #one-path-js"], ->
try
ok file-exists one-path-js
eq one-js, file-read one-path-js
finally
file-delete one-path-js
# header
command-eq '-cpb test/data/empty.ls', [
"// Generated by LiveScript #{LiveScript.VERSION}"
]
# no-header
command-eq '-cpb --no-header test/data/empty.ls', [
''
]
# not using bare
command-eq '-cp --no-header test/data/empty.ls', [
'(function(){\n\n}).call(this);'
]
# json
json-content = '{\n "moo": 1,\n "foo": "string"\n}'
# implicit json
command-eq '-cp test/data/data.json.ls', [json-content ]
# explicit json
command-eq '-cp --json test/data/data.ls', [json-content]
# eval print json, explicit
command-eq '-je "@two" test/data/j.json', ['4']
# eval print json, implicit
command-eq '-e "@two" test/data/j.json', ['4']
# map, basic
command-eq '-c --debug --map linked test/data/empty.ls', [
"#{normalize 'test/data/empty.ls'} => #{normalize 'test/data/empty.js'}, #{normalize 'test/data/empty.js.map'}"
], ->
try
ok file-exists 'test/data/empty.js'
ok file-exists 'test/data/empty.js.map'
ok //empty\.js\.map//.test file-read 'test/data/empty.js'
finally
file-delete 'test/data/empty.js'
file-delete 'test/data/empty.js.map'
# Use source maps for stack traces when running
# gkz/LiveScript#953
command-eq '-m embedded test/data/runtime-error.ls', [
'Failed at: test/data/runtime-error.ls'
/ReferenceError: doesNotExist is not defined\n at Object\.<anonymous> \(.*\/test\/data\/runtime-error\.ls:2:17\).*/
]