Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

v8cgi improvements #3

Open
wants to merge 1 commit into from

1 participant

@ondras

v8cgi detection; adapter improvements; fix in shellscript

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 7, 2011
  1. @ondras

    v8cgi improvements

    ondras authored
This page is out of date. Refresh to see the latest.
View
34 lib/pinf-loader-js/adapter/v8cgi.js
@@ -4,7 +4,10 @@
var API;
var SYSTEM = system,
- FS = require("fs");
+ FS = require("fs"),
+ HTTP = require("http"),
+ PROCESS = require("process")
+ ;
exports.init = function(api)
{
@@ -62,7 +65,10 @@ exports.init = function(api)
api.SYSTEM.parseArgs(SYSTEM.args);
- api.SYSTEM.exec = null;
+ api.SYSTEM.exec = function(command, callback) {
+ var output = new PROCESS.Process().exec(command);
+ callback(output, "");
+ };
/*
api.UTIL.setTimeout = function(callback, timeout)
@@ -108,7 +114,13 @@ exports.init = function(api)
api.FILE.mkdirs = function(filename)
{
- throw new Error("NYI - FILE.mkdirs");
+ var todo = filename.split("/");
+ var parts = [];
+ while (todo.length) {
+ parts.push(todo.shift());
+ var dir = new FS.Directory(parts.join("/") + "/");
+ if (!dir.exists()) { dir.create(); }
+ }
}
api.FILE.write = function(filename, data, encoding)
@@ -117,12 +129,24 @@ exports.init = function(api)
}
api.FILE.rename = function(from, to)
{
- throw new Error("NYI - FILE.rename");
+ new FS.File(from).move(to);
+ }
+ api.FILE.readdir = function(path) {
+ var results = [];
+ var dir = new FS.Directory(path);
+ results = results.concat(dir.listFiles());
+ results = results.concat(dir.listDirectories());
+ return results;
}
api.NET.download = function(url, path, callback)
{
- throw new Error("NYI - NET.download");
+ var request = new HTTP.ClientRequest(url);
+ var response = request.send(true);
+ var f = new FS.File(path).open("w");
+ f.write(response.data)
+ f.close();
+ callback({status:response.status});
}
api.JSON.parse = JSON.parse;
View
3  lib/pinf-loader-js/loader.js
@@ -90,8 +90,7 @@ var boot = exports.boot = function(options)
// Test for v8cgi
if (!adapter) {
try {
- var jsonRpcHandlerId = "jsonRpcHandler.js";
- if (typeof require(jsonRpcHandlerId).jsonRpcHandler !== "undefined")
+ if (typeof v8cgi !== "undefined")
{
adapter = "v8cgi";
}
View
2  pinf-loader.sh
@@ -1,6 +1,6 @@
#!/bin/bash
-BASE_PATH=$(dirname $(readlink $0))
+BASE_PATH=$(dirname $(readlink -f $0))
# TODO: Only match until first non-option argument is found. i.e. argument not prefixed by '-'
PLATFORM_ALIAS=$(echo "$@" | perl -lpe '($_) = /\s*--platform\s*(\S*)\s*/')
PLATFORM_BIN_NAME=$PLATFORM_ALIAS
Something went wrong with that request. Please try again.