Skip to content

Commit 5b86a66

Browse files
committed
Merge scripts/makeIconkit.js and scripts/updateTranslations.js from master
Fixes the scripts when used as a npm package script
1 parent d18baf5 commit 5b86a66

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

scripts/makeIconkit.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,18 @@ const readJSON = (filename) => {
1414
}
1515
};
1616

17-
const workspaces = readJSON('/package.json').workspaces || [];
17+
// Determine workspaces / dependencies
18+
const packageJson = readJSON('/package.json');
19+
const workspaces = packageJson.workspaces || [];
20+
const qwcDeps = Object.keys(packageJson.dependencies ?? {qwc2: "0"}).filter(dep => dep.startsWith("qwc"));
1821

1922
let icons = [];
2023
for (const workspace of workspaces) {
2124
icons = icons.concat(glob.sync(workspace + "/icons/*.svg"));
2225
}
26+
for (const qwcDep of qwcDeps) {
27+
icons = icons.concat(glob.sync('node_modules/' + qwcDep + '/icons/*.svg'));
28+
}
2329
icons = icons.concat(glob.sync("icons/*.svg"));
2430

2531
// Filter duplicate icons (user icons can override submodule icons, hence reverse)

scripts/updateTranslations.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const listDir = (dir, pattern) => {
5454
let results = [];
5555
const list = fs.readdirSync(dir);
5656
list.forEach((file) => {
57-
if (file === 'node_modules') {
57+
if (file === 'node_modules' || file === 'dist') {
5858
return;
5959
}
6060
const path = dir + '/' + file;
@@ -91,8 +91,10 @@ const updateTsConfig = (topdir, tsconfig, collectedMsgIds = null) => {
9191
return msgIds;
9292
};
9393

94-
// Determine workspaces
95-
const workspaces = readJSON('/package.json').workspaces || [];
94+
// Determine workspaces / dependencies
95+
const packageJson = readJSON('/package.json');
96+
const workspaces = packageJson.workspaces || [];
97+
const qwcDeps = Object.keys(packageJson.dependencies ?? {qwc2: "0"}).filter(dep => dep.startsWith("qwc"));
9698

9799
// Generate workspace translations
98100
let collectedMsgIds = new Set();
@@ -143,6 +145,10 @@ for (const lang of config.languages || []) {
143145
for (const workspace of workspaces) {
144146
data = merge(data, readJSON('/' + workspace + '/static/translations/' + lang + '.json'));
145147
}
148+
// Merge translations from dependencies
149+
for (const qwcDep of qwcDeps) {
150+
data = merge(data, readJSON('/node_modules/' + qwcDep + '/static/translations/' + lang + '.json'));
151+
}
146152

147153
// Revert to original values for strings specified in overrides
148154
for (const path of config.overrides || []) {

0 commit comments

Comments
 (0)