From 38f7c8399ea1f5a170c86c1f1577ed19b3f92b66 Mon Sep 17 00:00:00 2001 From: nightwing Date: Wed, 8 Jun 2016 13:17:29 +0000 Subject: [PATCH] fix error in cs50 workspace --- integrations/scripts/update.sh | 75 ++++++++++++++++++++++++++++++++ plugins/c9.ide.panels/panel.js | 2 +- plugins/c9.ide.server/plugins.js | 14 ++++++ plugins/c9.ide.tree/tree.js | 2 +- 4 files changed, 91 insertions(+), 2 deletions(-) create mode 100755 integrations/scripts/update.sh diff --git a/integrations/scripts/update.sh b/integrations/scripts/update.sh new file mode 100755 index 00000000..4ad703e3 --- /dev/null +++ b/integrations/scripts/update.sh @@ -0,0 +1,75 @@ +#!/bin/bash +set -e +cd `dirname $0`/.. + +NAME=$1 +URL=$2 +if [ "$NAME" == "" ]; then + echo "add name [url]" + exit 0 +fi + +if [ "$URL" == "" ]; then + URL=git@github.com:c9/$NAME.git +fi + +if [ -d $NAME/.git ]; then + pushd $NAME + OLD_URL=$(git config --get remote.origin.url) + if [ "$OLD_URL" != "$URL" ]; then + echo "folder $NAME exists and points to $OLD_URL" + exit 1 + fi + git fetch origin + popd +else + mkdir -p $NAME + git clone $URL $NAME +fi + +pushd $NAME +HASH=$(git rev-parse --revs-only refs/remotes/origin/master) +popd + +[ -f ./config.json ] || echo "{}" > ./config.json +node -e ' + var name = "'$NAME'"; + var url = "'$URL'"; + var hash = "'$HASH'" + var fs = require("fs"); + + function updateJSON(path, fn) { + var text = fs.readFileSync(path, "utf8"); + var indent = text.match(/^\s*(?=")/m); + indent = indent && indent[0] || 4; + console.log(indent) + var r = JSON.parse(text); + r = fn(r) || r; + text = JSON.stringify(r, null, indent) + "\n"; + fs.writeFileSync(path, text, "utf8"); + } + + updateJSON("./config.json", function(config) { + var packages = config.packages || (config.packages = {}); + config.packages[name] = { + name: name, + hash: hash, + url: url, + }; + }); + updateJSON("../package.json", function(package) { + var deps = package.dependencies; + console.log(deps[name], hash) + deps[name] = deps[name].replace(/#[a-f\d]+$/i, "#" + hash) + console.log(deps[name], hash) + }); + updateJSON("../npm-shrinkwrap.json", function(package) { + var deps = package.dependencies; + deps[name].from = deps[name].from.replace(/#[a-f\d]+$/i, "#" + hash); + deps[name].resolved = deps[name].resolved.replace(/#[a-f\d]+$/i, "#" + hash); + }); +' + +rm -rf "../node_modules/$NAME" +ln -s `pwd`/$NAME `pwd`/../node_modules/$NAME + diff --git a/plugins/c9.ide.panels/panel.js b/plugins/c9.ide.panels/panel.js index f1245f4b..f03e67d8 100644 --- a/plugins/c9.ide.panels/panel.js +++ b/plugins/c9.ide.panels/panel.js @@ -368,7 +368,7 @@ define(function(require, module, exports) { /** * @property {HTMLElement} container */ - get container(){ return aml.$ext; }, + get container(){ return aml && aml.$ext; }, /** * The area that this panel is a part of. diff --git a/plugins/c9.ide.server/plugins.js b/plugins/c9.ide.server/plugins.js index e92571bd..57e6f333 100644 --- a/plugins/c9.ide.server/plugins.js +++ b/plugins/c9.ide.server/plugins.js @@ -96,6 +96,20 @@ define(function(require, exports, module) { }; })); + try { + statics.addStatics( + fs.readdirSync(__dirname + "/../../integrations/").map(function(plugin) { + if (/^scripts$|\.(json|sh)$/.test(plugin)) + return; + return { + path: __dirname + "/../../integrations/" + plugin, + mount: "/plugins/" + plugin + }; + }).filter(Boolean) + ); + } catch(e) { + } + statics.addStatics(fs.readdirSync(__dirname + "/../") .filter(function(path) { if (path in blacklist) diff --git a/plugins/c9.ide.tree/tree.js b/plugins/c9.ide.tree/tree.js index 80c92016..25b6be20 100644 --- a/plugins/c9.ide.tree/tree.js +++ b/plugins/c9.ide.tree/tree.js @@ -1102,7 +1102,7 @@ define(function(require, exports, module) { expandedList[id] = node; } }); - callback(err); + callback && callback(err); tree.provider.on("changeScrollTop", scrollHandler); emit("refreshComplete");