diff --git a/scripts/dtsgenerator.js b/scripts/dtsgenerator.js index 355b277d23fd..810f358d16dc 100644 --- a/scripts/dtsgenerator.js +++ b/scripts/dtsgenerator.js @@ -1,3 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + const findup = require('findup'); const resolve = require('resolve'); const fs = require('fs'); @@ -154,15 +173,15 @@ generator.then(() => { function buildEuiTokensObject() { // reduce over the tokens list as a few of the tokens are used multiple times and must be // filtered down to a list - const i18ndefs = require('../i18ntokens.json').reduce( - ({ definitions, tokens }, def) => { - if (tokens.has(def.token)) { + const { i18ndefs } = require('../i18ntokens.json').reduce( + ({ i18ndefs, tokens }, def) => { + if (!tokens.has(def.token)) { tokens.add(def.token); - definitions.push(def); + i18ndefs.push(def); } - return definitions; + return { i18ndefs, tokens }; }, - { definitions: [], tokens: new Set() } + { i18ndefs: [], tokens: new Set() } ); return ` declare module '@elastic/eui' {