From 080e4a0641a889951cc3874a41a144eb8d4629f8 Mon Sep 17 00:00:00 2001 From: spalger Date: Wed, 14 Jun 2017 15:42:56 -0700 Subject: [PATCH] [generate] handle methods with more than one namespace --- scripts/generate/js_api.js | 10 +++++----- scripts/generate/templates/api_file.tmpl | 7 ++++++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/scripts/generate/js_api.js b/scripts/generate/js_api.js index edaa1f203..a1b971149 100644 --- a/scripts/generate/js_api.js +++ b/scripts/generate/js_api.js @@ -75,11 +75,11 @@ module.exports = function (branch, done) { // collect the namespaces from the action locations var namespaces = _.filter(_.map(actions, function (action) { - if (~action.location.indexOf('.')) { - var path = action.location.split('.').slice(0, -1); - _.pull(path, 'prototype'); - return path.join('.'); - } + return action.location + .split('.') + .slice(0, -1) + .filter(step => step !== 'prototype') + .join('.prototype.') })); // seperate the proxy actions diff --git a/scripts/generate/templates/api_file.tmpl b/scripts/generate/templates/api_file.tmpl index daf749b3d..569de5035 100644 --- a/scripts/generate/templates/api_file.tmpl +++ b/scripts/generate/templates/api_file.tmpl @@ -10,7 +10,12 @@ var api = module.exports = {}; api._namespaces = <%= stringify(namespaces) %>;<% _.each(actions, function (action) { - var namespace = action.location.split('.').shift(); + const namespace = action.location + .split('.') + .slice(0, -1) + .filter(step => step !== 'prototype') + .join('.prototype.'); + if (_.include(namespaces, namespace)) { _.pull(namespaces, namespace); %>