Skip to content
This repository has been archived by the owner on Aug 4, 2020. It is now read-only.

Latest commit

 

History

History
47 lines (37 loc) · 1.14 KB

HelloWorld.md

File metadata and controls

47 lines (37 loc) · 1.14 KB

Hello World

This is an example of "Hello World" implemented with JavaScript and mweave.js

helloworld.js

    console.log("Hello World");

Processing this with the command--

    node cli.js HelloWorld.md

Should yield the script helloworld.js containing only

    console.log("Hello World");

Let us tes this!

We are just going to pop open the results and see if they are what we expect.

test_helloworld.js

    var fs = require("fs");
    fs.readFile("helloworld.js", function (err, buf) {
        var expected, s;
        if (err) {
            console.error("Test filed on helloworld.js: " + err);
            process.exit(1);
        }
        expected = 'console.log("Hello World");';
        s = buf.toString();
        if (s === expected) {
            console.log("Yippee! helloworld.js was rendered correctly!");
        } else {
            console.error("Something went wrong.");
            console.error("      s: [" + s + "]");
            console.error("expected [" + expected + "]");
            process.exit(1);
        }
    });