From d568134d30d0fa3344c50f4e87cf898941d2f735 Mon Sep 17 00:00:00 2001 From: Artem Ufimtcev Date: Fri, 25 Aug 2023 18:04:25 +0200 Subject: [PATCH] Exclude isNonVirtualRoot group from name path --- exporter.json | 45 ++++++++++++++++++--------------------- src/functions.js | 55 +++++++++++++++++++++++++++--------------------- 2 files changed, 51 insertions(+), 49 deletions(-) diff --git a/exporter.json b/exporter.json index 5c58878..3f09c92 100644 --- a/exporter.json +++ b/exporter.json @@ -1,26 +1,21 @@ { - "id": "io.supernova.flutter-styles", - "name": "Flutter", - "description": "Flutter token and style exporter", - "source_dir": "src", - "version": "1.2.6", - "tags": [ - "Flutter", - "Dart", - "Tokens", - "Styles" - ], - "author": "Artem Ufimtcev", - "organization": "Supernova", - "homepage": "https://supernova.io", - "usesBrands": true, - "config": { - "output": "output.json", - "sources": "sources.json", - "js": "src/functions.js" - }, - "engines": { - "pulsar": "1.0.0", - "supernova": "1.0.0" - } -} \ No newline at end of file + "id": "io.supernova.flutter-styles", + "name": "Flutter", + "description": "Flutter token and style exporter", + "source_dir": "src", + "version": "1.2.7", + "tags": ["Flutter", "Dart", "Tokens", "Styles"], + "author": "Artem Ufimtcev", + "organization": "Supernova", + "homepage": "https://supernova.io", + "usesBrands": true, + "config": { + "output": "output.json", + "sources": "sources.json", + "js": "src/functions.js" + }, + "engines": { + "pulsar": "1.0.0", + "supernova": "1.0.0" + } +} diff --git a/src/functions.js b/src/functions.js index 6d0db72..4fc9102 100644 --- a/src/functions.js +++ b/src/functions.js @@ -1,49 +1,56 @@ /** - * - * @param {string} text - * @param {string} indentationString - * + * + * @param {string} text + * @param {string} indentationString + * * @returns {string} */ function createDocumentationComment(text, indentationString) { - return text.trim().split("\n").map((line) => `${indentationString}/// ${line}`).join("\n") + return text + .trim() + .split("\n") + .map((line) => `${indentationString}/// ${line}`) + .join("\n"); } /** - * - * @param {{name: string, isRoot: boolean, path: Array}} tokenGroup - * + * + * @param {{name: string, isRoot: boolean, path: Array}} tokenGroup + * * @returns {Array} */ function createFullTokenGroupPath(tokenGroup) { - if (tokenGroup.isRoot) { - return [] - } else { - return tokenGroup.path.concat(tokenGroup.name) - } + if (tokenGroup.isRoot || tokenGroup.isNonVirtualRoot) { + return []; + } else { + return tokenGroup.path.concat(tokenGroup.name); + } } /** - * + * * @param {Array} lhs * @param {Array} rhs - * + * * @returns {Array} */ function arrayConcat(lhs, rhs) { - return lhs.concat(rhs) + return lhs.concat(rhs); } /** - * - * @param {Array} array - * @param {string} separator + * + * @param {Array} array + * @param {string} separator */ function arrayJoin(array, separator) { - return array.join(separator) + return array.join(separator); } -Pulsar.registerFunction("createDocumentationComment", createDocumentationComment) -Pulsar.registerFunction("createFullTokenGroupPath", createFullTokenGroupPath) -Pulsar.registerFunction("arrayConcat", arrayConcat) -Pulsar.registerFunction("arrayJoin", arrayJoin) \ No newline at end of file +Pulsar.registerFunction( + "createDocumentationComment", + createDocumentationComment +); +Pulsar.registerFunction("createFullTokenGroupPath", createFullTokenGroupPath); +Pulsar.registerFunction("arrayConcat", arrayConcat); +Pulsar.registerFunction("arrayJoin", arrayJoin);