2
2
<!-- https://github.com/jashkenas/coffee-script/raw/master/extras/coffee-script.js -->
3
3
<script src =" coffee-script.js" language =" JScript" />
4
4
<script language =" JScript" >
5
- (function () {
6
-
5
+ (function() {
6
+
7
7
var args = [];
8
- for(var i = 0; i < WScript.Arguments.Length; i++) {
8
+ for (var i = 0; i < WScript.Arguments.Length; i++) {
9
9
args.push(WScript.Arguments.Item(i));
10
10
}
11
11
12
- //http://ss64. com/vb/filesystemobject.html
12
+ // FileSystemObject: http://msdn.microsoft. com/en-us/library/bkx696eh.aspx
13
13
var fso = new ActiveXObject("Scripting.FileSystemObject");
14
14
15
- var isfolder = (args[0] && fso.folderexists (args[0]));
16
-
15
+ var isfolder = (args[0] && fso.folderExists (args[0]));
16
+
17
17
if (isfolder) {
18
- f = fso.getfolder (args[0]);
19
- e = new Enumerator(f.files);
20
- for( ; !e.atEnd(); e.moveNext() ) {
21
- if (e.item().path.toLowerCase().lastIndexOf('.coffee') != -1) {
22
- convert(e.item(),args[1]);
23
- }
24
- }
18
+ f = fso.getFolder (args[0]);
19
+ e = new Enumerator(f.files);
20
+ for ( ; !e.atEnd(); e.moveNext()) {
21
+ if (e.item().path.toLowerCase().lastIndexOf('.coffee') != -1) {
22
+ convert(e.item(), args[1]);
23
+ }
24
+ }
25
25
}
26
26
else {
27
- convert(args[0],args[1])
28
- }
29
-
27
+ convert(args[0], args[1])
28
+ }
29
+
30
30
})();
31
31
32
32
33
- function convert(input,output) {
34
-
35
- var fso = new ActiveXObject("Scripting.FileSystemObject");
36
-
37
- if (!input) {
38
- input = WScript.StdIn;
39
- }
40
-
41
-
42
- if (output) {
43
- if (fso.folderexists(output)) {
44
- output = output + '\\' + fso.getfile(input).name.replace('\.coffee','.js')
33
+ function convert(input, output) {
34
+
35
+ var fso = new ActiveXObject("Scripting.FileSystemObject");
36
+
37
+ if (!input) {
38
+ input = WScript.StdIn;
39
+ }
40
+
41
+ if (output) {
42
+ if (fso.folderExists(output)) {
43
+ output = output + '\\' + fso.getFile(input).name.replace('\.coffee', '.js')
44
+ }
45
+ output = fso.CreateTextFile(output);
46
+ }
47
+ else {
48
+ output = WScript.StdOut;
49
+ }
50
+
51
+ input = fso.OpenTextFile(input);
52
+
53
+ // Read all input data into string
54
+ var chunks = [];
55
+ while (!input.AtEndOfStream)
56
+ chunks.push(input.ReadAll());
57
+ var coffee = chunks.join('');
58
+
59
+ try {
60
+ var js = CoffeeScript.compile(coffee);
61
+ output.Write(js);
62
+ }
63
+ catch (err) {
64
+ WScript.StdErr.WriteLine(err.message);
65
+ WScript.Quit(1);
45
66
}
46
- output = fso.CreateTextFile(output);
47
- }
48
- else {
49
- output = WScript.StdOut;
50
- }
51
-
52
- input = fso.OpenTextFile(input);
53
-
54
- // Read all input data into string
55
- var chunks = [];
56
- while (!input.AtEndOfStream)
57
- chunks.push(input.ReadAll());
58
- var coffee = chunks.join('');
59
-
60
- try {
61
- var js = CoffeeScript.compile(coffee);
62
- output.Write(js);
63
- }
64
- catch (err) {
65
- WScript.StdErr.WriteLine(err.message);
66
- WScript.Quit(1);
67
- }
68
-
69
- }
70
-
67
+ }
71
68
</script >
72
69
</job >
0 commit comments