First release, remove not used lines from gitignore
This commit is contained in:
parent
c0bfb3b062
commit
d28e1cb4a6
85 changed files with 7205 additions and 50 deletions
19
tools/coffee/README.md
Normal file
19
tools/coffee/README.md
Normal file
|
@ -0,0 +1,19 @@
|
|||
# CoffeeScript compiler for Windows
|
||||
|
||||
A simple command-line utilty for Windows that will compile `*.coffee` files to JavaScript `*.js` files using [CoffeeScript](http://jashkenas.github.com/coffee-script/) and the venerable Windows Script Host, ubiquitous on Windows since the 90s.
|
||||
|
||||
## Usage
|
||||
|
||||
To use it, invoke `coffee.cmd` like so:
|
||||
|
||||
coffee input.coffee output.js
|
||||
|
||||
If an output is not specified, it is written to `stdout`. In neither an input or output are specified then data is assumed to be on `stdin`. For example:
|
||||
|
||||
type input.coffee | coffee > output.js
|
||||
|
||||
Errors are written to `stderr`.
|
||||
|
||||
In the `test` directory there's a version of the standard CoffeeScript tests which can be kicked off using `test.cmd`. The test just attempts to compile the *.coffee files but doesn't execute them.
|
||||
|
||||
To upgrade to the latest CoffeeScript simply replace `coffee-script.js` from the upstream https://github.com/jashkenas/coffee-script/blob/master/extras/coffee-script.js (the tests will likely need updating as well, if you want to run them).
|
12
tools/coffee/coffee-script.js
Normal file
12
tools/coffee/coffee-script.js
Normal file
File diff suppressed because one or more lines are too long
2
tools/coffee/coffee.cmd
Normal file
2
tools/coffee/coffee.cmd
Normal file
|
@ -0,0 +1,2 @@
|
|||
::For convenience
|
||||
@cscript //nologo "%~dp0coffee.wsf" %*
|
93
tools/coffee/coffee.wsf
Normal file
93
tools/coffee/coffee.wsf
Normal file
|
@ -0,0 +1,93 @@
|
|||
<job>
|
||||
<!-- https://github.com/jashkenas/coffee-script/raw/master/extras/coffee-script.js -->
|
||||
<script src="coffee-script.js" language="JScript" />
|
||||
<script language="JScript">
|
||||
(function() {
|
||||
|
||||
var args = [];
|
||||
for (var i = 0; i < WScript.Arguments.Length; i++) {
|
||||
args.push(WScript.Arguments.Item(i));
|
||||
}
|
||||
|
||||
// FileSystemObject: http://msdn.microsoft.com/en-us/library/bkx696eh.aspx
|
||||
var fso = new ActiveXObject("Scripting.FileSystemObject");
|
||||
|
||||
var isfolder = (args[0] && fso.folderExists(args[0]));
|
||||
|
||||
if (isfolder) {
|
||||
f = fso.getFolder(args[0]);
|
||||
e = new Enumerator(f.files);
|
||||
for (; !e.atEnd(); e.moveNext()) {
|
||||
if (e.item().path.toLowerCase().lastIndexOf('.coffee') != -1) {
|
||||
convert(e.item(), args[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
convert(args[0], args[1])
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
|
||||
function convert(input, output) {
|
||||
|
||||
var fso = new ActiveXObject("Scripting.FileSystemObject");
|
||||
|
||||
if (output) {
|
||||
// if output specifies a folder name, output filename is same as input filename with .coffee extension
|
||||
if (fso.folderExists(output)) {
|
||||
output = output + '\\' + fso.getFile(input).name.replace('\.coffee', '.js')
|
||||
}
|
||||
}
|
||||
|
||||
var coffee;
|
||||
if (!input) {
|
||||
// Read all input data from STDIN
|
||||
var chunks = [];
|
||||
while (!WScript.StdIn.AtEndOfStream)
|
||||
chunks.push(WScript.StdIn.ReadAll());
|
||||
coffee = chunks.join('');
|
||||
}
|
||||
else {
|
||||
coffee = readUtf8(input);
|
||||
}
|
||||
|
||||
try {
|
||||
var js = CoffeeScript.compile(coffee);
|
||||
|
||||
if (!output) {
|
||||
WScript.StdOut.Write(js);
|
||||
}
|
||||
else {
|
||||
writeUtf8(output, js);
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
WScript.StdErr.WriteLine(err.message);
|
||||
WScript.Quit(1);
|
||||
}
|
||||
}
|
||||
|
||||
function readUtf8(filename) {
|
||||
var stream = new ActiveXObject("ADODB.Stream");
|
||||
stream.Open();
|
||||
stream.Type = 2; // Text
|
||||
stream.Charset = 'utf-8';
|
||||
stream.LoadFromFile(filename);
|
||||
var text = stream.ReadText();
|
||||
stream.Close();
|
||||
return text;
|
||||
}
|
||||
|
||||
function writeUtf8(filename, text) {
|
||||
var stream = new ActiveXObject("ADODB.Stream");
|
||||
stream.Open();
|
||||
stream.Type = 2; // Text
|
||||
stream.Charset = 'utf-8';
|
||||
stream.WriteText(text);
|
||||
stream.SaveToFile(filename, 2);
|
||||
stream.Close();
|
||||
}
|
||||
</script>
|
||||
</job>
|
Loading…
Add table
Add a link
Reference in a new issue