Skip to content

Commit

Permalink
Add env:abort stub for template in asinit script (#670)
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxGraey authored and dcodeIO committed Jun 19, 2019
1 parent f5b00c8 commit 4802a0a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions bin/asinit
Expand Up @@ -26,7 +26,6 @@ const rl = require("readline").createInterface({

const projectDir = path.resolve(process.argv[2]);
const compilerDir = path.join(__dirname, "..");
const compilerVersion = require(path.join(compilerDir, "package.json")).version;
const assemblyDir = path.join(projectDir, "assembly");
const tsconfigFile = path.join(assemblyDir, "tsconfig.json");
const tsconfigBase = path.relative(assemblyDir, path.join(compilerDir, "std", "assembly.json"));
Expand Down Expand Up @@ -245,7 +244,13 @@ function ensureIndexJs() {
fs.writeFileSync(indexFile, [
"const fs = require(\"fs\");",
"const compiled = new WebAssembly.Module(fs.readFileSync(__dirname + \"/build/optimized.wasm\"));",
"const imports = {};",
"const imports = {",
" env: {",
" abort(_msg, _file, line, column) {",
" console.error(\"abort called at index.ts:\" + line + \":\" + column);",
" }",
" }",
"};",
"Object.defineProperty(module, \"exports\", {",
" get: () => new WebAssembly.Instance(compiled, imports).exports",
"});",
Expand Down

0 comments on commit 4802a0a

Please sign in to comment.