Merge remote-tracking branch 'origin/master' into milliseconds

pull/242/head
Lennart Kats 2016-01-20 10:48:39 +01:00
commit 6686725d76
12 zmienionych plików z 225 dodań i 18 usunięć

Wyświetl plik

@ -24,7 +24,7 @@ module.exports = function setup(mount, vfs, mountOptions) {
else if (err.code === "ENOTREADY") res.statusCode = 503;
else if (err.code === "EISDIR") res.statusCode = 503;
else res.statusCode = 500;
var message = (err.stack || err) + "\n";
var message = (err.message || err.toString()) + "\n";
res.setHeader("Content-Type", "text/plain");
res.setHeader("Content-Length", Buffer.byteLength(message));
res.end(message);

9
node_modules/vfs-local/localfs.js wygenerowano vendored
Wyświetl plik

@ -322,8 +322,8 @@ module.exports = function setup(fsOptions) {
var isError = true;
if (isError) {
var err = new Error("EACCESS: '" + path + "' not in '" + localRoot + "'");
err.code = "EACCESS";
var err = new Error("EACCES: '" + path + "' not in '" + localRoot + "'");
err.code = "EACCES";
return callback(err);
}
}
@ -2335,6 +2335,11 @@ module.exports = function setup(fsOptions) {
}
function extend(name, options, callback) {
if (!name) {
var err = new Error("EACCES: Invalid extension name");
err.code = "EACCES";
return callback(err);
}
var meta = {};
// Pull from cache if it's already loaded.

Wyświetl plik

@ -49,7 +49,7 @@ describe('vfs-local', function () {
});
it('should reject paths that resolve outside the root', function (done) {
vfs.resolve("/../test-local.js", {}, function (err, meta) {
expect(err).property("code").equals("EACCESS");
expect(err).property("code").equals("EACCES");
done();
});
});
@ -893,6 +893,12 @@ describe('vfs-local', function () {
});
});
});
it("should error with EACCES if the same extension name is empty", function (done) {
vfs.extend("", {file: __dirname + "/math.js"}, function (err, meta) {
expect(err).property("code").equal("EACCES");
done();
});
});
it("should allow a redefine if options.redefine is set", function (done) {
vfs.extend("test", {file: __dirname + "/math.js"}, function (err, meta) {
if (err) throw err;

Wyświetl plik

@ -1,7 +1,7 @@
{
"name": "c9",
"description": "New Cloud9 Client",
"version": "3.1.1064",
"version": "3.1.1100",
"author": "Ajax.org B.V. <info@ajax.org>",
"private": true,
"main": "bin/c9",
@ -56,7 +56,7 @@
"c9"
],
"c9plugins": {
"c9.ide.language": "#0cd08cf6af",
"c9.ide.language": "#780d31bf63",
"c9.ide.language.css": "#be07d72209",
"c9.ide.language.generic": "#352dca59a6",
"c9.ide.language.html": "#4f4d47a8bf",
@ -66,7 +66,7 @@
"c9.ide.language.javascript.eslint": "#3127e1eba1",
"c9.ide.language.javascript.tern": "#f9ba3813d7",
"c9.ide.language.javascript.infer": "#90fe920111",
"c9.ide.language.jsonalyzer": "#333e5262dc",
"c9.ide.language.jsonalyzer": "#47a64de05d",
"c9.ide.collab": "#10c224f9b8",
"c9.ide.local": "#a6e689e33b",
"c9.ide.find": "#e33fbaed2f",
@ -91,8 +91,8 @@
"c9.ide.imgeditor": "#612e75ef4f",
"c9.ide.immediate": "#a962119bec",
"c9.ide.installer": "#0fde9f0067",
"c9.ide.language.python": "#c6a5164066",
"c9.ide.language.go": "#87ae616645",
"c9.ide.language.python": "#7ab2553387",
"c9.ide.language.go": "#16f06b0023",
"c9.ide.mount": "#f46dc6dcd2",
"c9.ide.navigate": "#38ae100ea1",
"c9.ide.newresource": "#981a408a7b",

Wyświetl plik

@ -16,8 +16,7 @@ function plugin(options, imports, register) {
track: function() {},
identify: function() {},
logClean: function() {},
trackClean: function() {},
identifyClean: function() {},
trackClean: function() {}
}
});
}

Wyświetl plik

@ -122,7 +122,7 @@ function plugin(options, imports, register) {
var allowedErrorKeys = [
"message", "projectState", "premium", "retryIn", "progress",
"oldHost", "blocked", "className", "errors"
"oldHost", "blocked", "className", "errors", "subtype"
];
allowedErrorKeys.forEach(function(key) {

Wyświetl plik

@ -212,7 +212,8 @@ define(function(require, exports, module) {
} else if (body.indexOf("ENOENT") !== -1 || statusCode == 404) {
next(new error.NotFound("File '" + path + "' could not be found!"));
} else {
delete req.session.ws[req.ws];
if (req.session.ws)
delete req.session.ws[req.ws];
var json;
try {

Wyświetl plik

@ -34,7 +34,7 @@ module.exports = function(methods, vfsHome, vfsWorkspace) {
function wrap(name, excluded) {
if (excluded) {
return function(){
return function() {
vfsWorkspace[name].apply(vfsWorkspace, arguments);
};
}
@ -43,11 +43,12 @@ module.exports = function(methods, vfsHome, vfsWorkspace) {
var args = Array.prototype.slice.call(arguments);
PATH_OPTIONS.forEach(function(o) {
options[o] = options[o] && substituteTilde(options[o]);
if (options[o] && typeof options[o] == "string")
options[o] = substituteTilde(options[o]);
});
args[1] = options;
if (path.charAt(0) == "~") {
if (typeof path == "string" && path.charAt(0) == "~") {
args[0] = substituteTilde(path);
vfsHome[name].apply(vfsHome, args);

Wyświetl plik

@ -0,0 +1,142 @@
#!/usr/bin/env node
/*global describe it before after beforeEach afterEach */
"use strict";
"use server";
require("c9/inline-mocha")(module);
var assert = require("assert-diff");
var async = require("async");
var sinon = require("sinon");
var vfs = require("vfs-local");
var vfsProxy = require("./vfs_proxy");
describe(__filename, function(){
var proxy, home, workspace;
before(function() {
home = vfs({
root: __dirname,
testing: true,
checkSymlinks: true
});
home.root = __dirname;
workspace = vfs({
root: __dirname + "/views",
testing: true,
checkSymlinks: true
});
});
beforeEach(function() {
proxy = vfsProxy(Object.keys(home), home, workspace);
});
it("should use home for files starting with ~ ", function(done) {
home.readfile = sinon.stub().callsArgWith(2, null, "home");
workspace.readfile = sinon.stub().callsArgWith(2, null, "workspace");
proxy.readfile("~/foo.txt", {}, function(err, data) {
assert(!err, err);
assert.equal(data, "home");
done();
});
});
it("should use workspace for files not starting with ~ ", function(done) {
home.readfile = sinon.stub().callsArgWith(2, null, "home");
workspace.readfile = sinon.stub().callsArgWith(2, null, "workspace");
proxy.readfile("foo.txt", {}, function(err, data) {
assert(!err, err);
assert.equal(data, "workspace");
done();
});
});
it("should expand ~ to paths relative to 'home'", function(done) {
home.readfile = function(path, options, callback) {
assert.equal(path, "/foo.txt");
callback(null, "home");
};
proxy.readfile("~/foo.txt", {}, function(err, data) {
assert(!err, err);
assert.equal(data, "home");
done();
});
});
it("should expand ~ in options", function(done) {
home.readfile = function(path, options, callback) {
assert.equal(path, "/foo.txt");
assert.equal(options.target, "/bar");
assert.equal(options.to, "/juhu");
assert.equal(options.from, "/kinners");
assert.equal(options.stuff, "~/stuff");
callback(null, "home");
};
proxy.readfile("~/foo.txt", {
target: "~/bar",
to: "~/juhu",
from: "~/kinners",
stuff: "~/stuff"
}, function(err, data) {
assert(!err, err);
assert.equal(data, "home");
done();
});
});
it("should expand some commands to absolute paths", function(done) {
home.execFile = function(path, options, callback) {
assert.equal(path, __dirname + "/foo.txt");
callback(null, "home");
};
proxy.execFile("~/foo.txt", {}, function(err, data) {
assert(!err, err);
assert.equal(data, "home");
done();
});
});
it("should not wrap some commands", function(done) {
async.eachSeries([
"connect",
"on",
"off",
"emit",
"extend",
"unextend",
"use",
"killtree"
], function(cmd, next) {
workspace[cmd] = function(path, options, callback) {
assert.equal(path, "~/foo.txt");
callback(null, "workspace");
};
proxy[cmd]("~/foo.txt", {}, function(err, data) {
assert(!err, err);
assert.equal(data, "workspace");
next();
});
}, done);
});
it("bad execFile arguments should not break the server", function(done) {
workspace.execFile = sinon.stub().callsArgWith(2, null, "done");
proxy.execFile(['ls', '-a'], {encoding: "utf8"}, function(err, data) {
assert(!err, err);
assert.equal(data, "done");
done();
});
});
});

Wyświetl plik

@ -83,6 +83,9 @@ module.exports = function(vfs, options) {
if (!options.file)
return callback(new error.Forbidden("Option 'file' is missing"));
if (typeof options.file != "string")
return callback(new error.Forbidden("Invalid option 'file'"));
if (extendDirectory) {
var file = options.file = path.normalize(path.join(extendDirectory, options.file));

Wyświetl plik

@ -0,0 +1,38 @@
#!/usr/bin/env node
/*global describe it before after beforeEach afterEach */
"use strict";
"use server";
require("c9/inline-mocha")(module);
var assert = require("assert-diff");
var path = require("path");
var vfs = require("vfs-local");
var vfsWrapper = require("./vfs_wrapper");
describe(__filename, function(){
describe("#extend", function() {
var wrapper;
beforeEach(function() {
var home = vfs({
root: path.normalize(__dirname + "/.."),
testing: true,
});
wrapper = vfsWrapper(home, {
root: __dirname
});
});
it("should return an error if file is not passed", function(done) {
wrapper.extend('foo', { file: {} ,encoding: "utf8"}, function(err, data) {
assert(err);
assert.equal(err.message, "Invalid option 'file'");
done();
});
});
});
});

Wyświetl plik

@ -168,6 +168,8 @@ function plugin(options, imports, register) {
});
var path = resolve(__dirname + "/../../build/output/latest.tar.gz");
fs.readlink(path, function(err, target) {
if (err) return next(err);
res.end((target || "").split(".")[0]);
});
});
@ -176,9 +178,19 @@ function plugin(options, imports, register) {
var filename = req.params.path;
var path = resolve(__dirname + "/../../build/output/" + filename);
res.writeHead(200, {"Content-Type": "application/octet-stream"});
var stream = fs.createReadStream(path);
stream.pipe(res);
stream.on("error", function(err) {
next(err);
});
stream.on("data", function(data) {
if (!res.headersSent)
res.writeHead(200, {"Content-Type": "application/octet-stream"});
res.write(data);
});
stream.on("end", function(data) {
res.end();
});
});
api.get("/configs/require_config.js", function(req, res, next) {