Initial asc browser bundle, see

This commit is contained in:
dcodeIO
2018-02-09 15:43:57 +01:00
parent cd9a3b5b95
commit 60728c38fd
6 changed files with 722 additions and 54 deletions

@ -46,8 +46,9 @@ tests.forEach(filename => {
const basename = filename.replace(/\.ts$/, "");
const stdout = createMemoryStream();
const stderr = createMemoryStream(true);
const stdout = asc.createMemoryStream();
const stderr = asc.createMemoryStream(chunk => process.stderr.write(chunk.toString().replace(/^(?!$)/mg, " ")));
stderr.isTTY = true;
var failed = false;
@ -135,28 +136,6 @@ tests.forEach(filename => {
});
});
function createMemoryStream(print) {
var stream = [];
if (stream.print = print)
stream.isTTY = process.stderr.isTTY;
stream.write = function(chunk) {
if (typeof chunk === "string") {
this.push(Buffer.from(chunk, "utf8"));
} else {
this.push(chunk);
}
if (stream.print)
process.stderr.write(chunk.toString().replace(/^(?!$)/mg, " "));
};
stream.toBuffer = function() {
return Buffer.concat(this);
};
stream.toString = function() {
return this.toBuffer().toString("utf8");
};
return stream;
}
if (failures) {
process.exitCode = 1;
console.log(chalk.red("ERROR: ") + failures + " compiler tests failed");