Sha256: b6946ad8892741f463e1ed43918894334d293d64e9444ce733a77ac678e52146

Contents?: true

Size: 1.54 KB

Versions: 2

Compression:

Stored size: 1.54 KB

Contents

var _ns_ = "wisp.wisp";
module.namespace = _ns_;
module.description = "Wisp program that reads wisp code from stdin and prints\n  compiled javascript code into stdout";
var fs = require("fs");
var path = require("path");
var Module = (require("module")).Module;
var start = (require("./repl")).start;
var str = (require("./runtime")).str;
var compile_ = (require("./compiler")).compile_;
var read_ = (require("./reader")).read_;;

var exit = function exit(error) {
  return error ?
    (function() {
      console.error(error);
      return process.exit(1);
    })() :
    process.exit(0);
};

var compile = function compile(input, output, uri) {
  var source = "";
  input.on("data", function onChunck(chunck) {
    return source = "" + source + chunck;
  });
  input.on("end", function onRead() {
    return (function() {
    try {
      return output.write(compile_(read_(source)));
    } catch (error) {
      return exit(error);
    }})();
  });
  input.on("error", exit);
  return output.on("error", exit);
};

var main = function main() {
  return process.argv.length < 3 ?
    (function() {
      process.stdin.resume();
      process.stdin.setEncoding("utf8");
      compile(process.stdin, process.stdout, process.cwd());
      return setTimeout(function() {
        return process.stdin.bytesRead === 0 ?
          (function() {
            process.stdin.removeAllListeners("data");
            return start();
          })() :
          void(0);
      }, 20);
    })() :
    Module._load(path.resolve((process.argv || 0)[2]), null, true);
};
exports.main = main

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ruby-wisp-source-0.8.0 vendor/node_modules/wisp/wisp.js
ruby-wisp-source-0.7.0 vendor/wisp.js