use getters for api versions in node

This commit is contained in:
spalger
2017-02-09 01:25:28 -07:00
parent 317c76f5d6
commit fa4c08748b
5 changed files with 32 additions and 17 deletions

View File

@ -15,7 +15,7 @@ module.exports = function (done) {
console.log(chalk.white.bold('wrote'), 'api index to', nodeApiIndex);
write(browserApiIndex, require('./templates').apiIndex({
write(browserApiIndex, require('./templates').apiIndexBrowser({
branches: utils.browserBranches
}), 'utf8');

View File

@ -1,14 +1,14 @@
module.exports = {
<%
branches.forEach(function (branch, i, list) {
var req = "require('./" + _.snakeCase(branch) + "')";
if (branch === utils.branches._default) {
print(" '_default': " + req + ',\n');
function printVersion(name) {
print(` get '${name}'() { return require('./${_.snakeCase(branch)}'); },\n`)
}
print(" '" + branch + "': " + req + (i === list.length - 1 ? '' : ',\n'));
if (branch === utils.branches._default) printVersion('_default');
printVersion(branch);
});
%>
};
%>};

View File

@ -0,0 +1,14 @@
module.exports = {
<%
branches.forEach(function (branch, i, list) {
var req = "require('./" + _.snakeCase(branch) + "')";
if (branch === utils.branches._default) {
print(" '_default': " + req + ',\n');
}
print(" '" + branch + "': " + req + (i === list.length - 1 ? '' : ',\n'));
});
%>
};

View File

@ -126,5 +126,6 @@ module.exports = {
apiMethods: templates.api_methods,
docsIndex: templates.docs_index,
apiIndex: templates.api_index,
apiIndexBrowser: templates.api_index_browser,
configurationDocs: templates.configuration_docs,
};