style-dictionary 3.9.1 → 3.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/examples/advanced/assets-base64-embed/package.json +1 -1
- package/examples/advanced/auto-rebuild-watcher/package.json +1 -1
- package/examples/advanced/component-cti/package.json +1 -1
- package/examples/advanced/create-react-app/package.json +1 -1
- package/examples/advanced/create-react-native-app/package.json +1 -1
- package/examples/advanced/custom-file-header/package.json +1 -1
- package/examples/advanced/custom-filters/package.json +1 -1
- package/examples/advanced/custom-formats-with-templates/package.json +1 -1
- package/examples/advanced/custom-parser/package.json +1 -1
- package/examples/advanced/custom-transforms/package.json +1 -1
- package/examples/advanced/font-face-rules/package.json +1 -1
- package/examples/advanced/format-helpers/package.json +1 -1
- package/examples/advanced/matching-build-files/package.json +1 -1
- package/examples/advanced/multi-brand-multi-platform/package.json +1 -1
- package/examples/advanced/node-modules-as-config-and-properties/package.json +1 -1
- package/examples/advanced/npm-module/package.json +1 -1
- package/examples/advanced/referencing_aliasing/package.json +1 -1
- package/examples/advanced/s3/package.json +1 -1
- package/examples/advanced/tokens-deprecation/package.json +1 -1
- package/examples/advanced/transitive-transforms/package.json +1 -1
- package/examples/advanced/variables-in-outputs/package.json +1 -1
- package/examples/advanced/yaml-tokens/package.json +1 -1
- package/lib/utils/combineJSON.js +15 -14
- package/package.json +1 -1
package/lib/utils/combineJSON.js
CHANGED
|
@@ -11,18 +11,18 @@
|
|
|
11
11
|
* and limitations under the License.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
require(
|
|
14
|
+
require("json5/lib/register");
|
|
15
15
|
require.extensions[".jsonc"] = require("./jsonc").register;
|
|
16
16
|
|
|
17
|
-
var { globSync }= require(
|
|
18
|
-
deepExtend = require(
|
|
19
|
-
path = require(
|
|
20
|
-
fs = require(
|
|
17
|
+
var { globSync } = require("glob"),
|
|
18
|
+
deepExtend = require("./deepExtend"),
|
|
19
|
+
path = require("path"),
|
|
20
|
+
fs = require("fs");
|
|
21
21
|
|
|
22
22
|
function traverseObj(obj, fn) {
|
|
23
23
|
for (let key in obj) {
|
|
24
24
|
fn.apply(null, [obj, key, obj[key]]);
|
|
25
|
-
if (obj[key] && typeof obj[key] ===
|
|
25
|
+
if (obj[key] && typeof obj[key] === "object") {
|
|
26
26
|
traverseObj(obj[key], fn);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -39,13 +39,14 @@ function traverseObj(obj, fn) {
|
|
|
39
39
|
* @param {Object[]} [parsers=[]] - Custom file parsers
|
|
40
40
|
* @returns {Object}
|
|
41
41
|
*/
|
|
42
|
-
function combineJSON(arr, deep, collision, source, parsers=[]) {
|
|
43
|
-
var i,
|
|
42
|
+
function combineJSON(arr, deep, collision, source, parsers = []) {
|
|
43
|
+
var i,
|
|
44
|
+
files = [],
|
|
44
45
|
to_ret = {};
|
|
45
46
|
|
|
46
47
|
for (i = 0; i < arr.length; i++) {
|
|
47
48
|
// Reverse to avoid introducing a breaking change
|
|
48
|
-
var new_files = globSync(arr[i], {}).reverse();
|
|
49
|
+
var new_files = globSync(arr[i], { posix: true }).reverse();
|
|
49
50
|
files = files.concat(new_files);
|
|
50
51
|
}
|
|
51
52
|
|
|
@@ -62,11 +63,11 @@ function combineJSON(arr, deep, collision, source, parsers=[]) {
|
|
|
62
63
|
|
|
63
64
|
// Iterate over custom parsers, if the file path matches the parser's
|
|
64
65
|
// pattern regex, use it's parse function to generate the object
|
|
65
|
-
parsers.forEach(({pattern, parse}) => {
|
|
66
|
+
parsers.forEach(({ pattern, parse }) => {
|
|
66
67
|
if (resolvedPath.match(pattern)) {
|
|
67
68
|
file_content = parse({
|
|
68
|
-
contents: fs.readFileSync(resolvedPath, {encoding:
|
|
69
|
-
filePath: resolvedPath
|
|
69
|
+
contents: fs.readFileSync(resolvedPath, { encoding: "UTF-8" }),
|
|
70
|
+
filePath: resolvedPath,
|
|
70
71
|
});
|
|
71
72
|
}
|
|
72
73
|
});
|
|
@@ -76,13 +77,13 @@ function combineJSON(arr, deep, collision, source, parsers=[]) {
|
|
|
76
77
|
file_content = deepExtend([file_content, require(resolvedPath)]);
|
|
77
78
|
}
|
|
78
79
|
} catch (e) {
|
|
79
|
-
e.message =
|
|
80
|
+
e.message = "Failed to load or parse JSON or JS Object: " + e.message;
|
|
80
81
|
throw e;
|
|
81
82
|
}
|
|
82
83
|
|
|
83
84
|
// Add some side data on each property to make filtering easier
|
|
84
85
|
traverseObj(file_content, (obj) => {
|
|
85
|
-
if (obj.hasOwnProperty(
|
|
86
|
+
if (obj.hasOwnProperty("value") && !obj.filePath) {
|
|
86
87
|
obj.filePath = filePath;
|
|
87
88
|
|
|
88
89
|
obj.isSource = source || source === undefined ? true : false;
|