issue #24069: make client assets available immediately upon npm extension install
authorSteve Hackbarth <stephenhackbarth@gmail.com>
Fri, 18 Jul 2014 15:49:39 +0000 (11:49 -0400)
committerSteve Hackbarth <stephenhackbarth@gmail.com>
Fri, 18 Jul 2014 15:49:39 +0000 (11:49 -0400)
node-datasource/main.js
node-datasource/routes/install_extension.js

index 6dd6649..25801b5 100755 (executable)
@@ -104,7 +104,7 @@ var app;
     };
     return dirMap[extension.location];
   };
-  var useClientDir = function (path, dir) {
+  var useClientDir = X.useClientDir = function (path, dir) {
     path = path.indexOf("npm") === 0 ? "/" + path : path;
     _.each(X.options.datasource.databases, function (orgValue, orgKey, orgList) {
       app.use("/" + orgValue + path, express.static(dir, { maxAge: 86400000 }));
index 5dafe61..e3363e2 100644 (file)
@@ -59,6 +59,13 @@ regexp:true, undef:true, strict:true, trailing:true, white:true */
           database: database,
           extension: path.join(__dirname, "../../node_modules", extensionName)
         }, callback);
+      },
+      // make the client-side assets immediately available to the webserver
+      // without the need for a datasource restart
+      useClientDir = function (callback) {
+        X.useClientDir("npm/" + extensionName + "/client",
+          path.join(__dirname, "../../node_modules", extensionName, "client"));
+        callback();
       };
 
     async.series([
@@ -66,7 +73,8 @@ regexp:true, undef:true, strict:true, trailing:true, white:true */
       validateUser,
       npmLoad,
       npmInstall,
-      buildExtension
+      buildExtension,
+      useClientDir
     ], function (err, results) {
       if (err) {
         console.log(err);