Fix downloading plugin and unpacking it. Working around #

pull/9/merge
Ruben Daniels 2015-02-12 22:15:55 +00:00
rodzic 6baf46cf59
commit 0438a92fbc
3 zmienionych plików z 8 dodań i 7 usunięć

Wyświetl plik

@ -529,7 +529,7 @@ define(function(require, exports, module) {
if (!template) if (!template)
template = "c9.ide.default"; template = "c9.ide.default";
var url = join(staticPrefix, "templates", template + ".tar.gz"); var url = staticPrefix + "/" + join("templates", template + ".tar.gz");
if (!url.match(/^http/)) if (!url.match(/^http/))
url = location.origin + url; url = location.origin + url;
@ -551,20 +551,21 @@ define(function(require, exports, module) {
if (err) if (err)
return handleError(err); return handleError(err);
// Download tar file with template for plugin
var pluginsDir = join("~", ".c9/plugins/_/"); var pluginsDir = join("~", ".c9/plugins/_/");
var pluginsDirAbsolute = pluginsDir.replace(/^~/, c9.home); var pluginsDirAbsolute = pluginsDir.replace(/^~/, c9.home);
var tarPath = join(pluginsDir, template + ".tar.gz"); var tarPath = join(pluginsDir, template + ".tar.gz");
var tarPathAbsolute = tarPath.replace(/^~/, c9.home); var tarPathAbsolute = tarPath.replace(/^~/, c9.home);
proc.execFile("curl", {
args: ["-L", url, "--create-dirs", "-o", tarPathAbsolute] // Download tar file with template for plugin
proc.execFile("bash", {
args: ["-c", ["curl", "-L", url, "--create-dirs", "-o", tarPathAbsolute].join(" ")]
}, function(err, stderr, stdout){ }, function(err, stderr, stdout){
if (err) if (err)
return handleError(err); return handleError(err);
// Untar tar file // Untar tar file
proc.execFile("tar", { proc.execFile("bash", {
args: ["-zxvf", tarPath, "-C", pluginsDirAbsolute] args: ["-c", ["tar", "-zxvf", tarPath, "-C", pluginsDirAbsolute].join(" ")]
}, function(err, stderr, stdout){ }, function(err, stderr, stdout){
if (err) if (err)
return handleError(err); return handleError(err);
@ -579,7 +580,7 @@ define(function(require, exports, module) {
fs.unlink(tarPath, function(){ fs.unlink(tarPath, function(){
// Add plugin to favorites // Add plugin to favorites
favs.addFavorite(pluginsDir, "plugins"); favs.addFavorite(dirname(pluginsDir), "plugins");
// Select and expand the folder of the plugin // Select and expand the folder of the plugin
tree.expandAndSelect(path); tree.expandAndSelect(path);