|
1 | 1 | const { join } = require("path");
|
2 |
| -const { cp, mkdir } = require("shelljs"); |
| 2 | +const { cp, mkdir, rm } = require("shelljs"); |
3 | 3 |
|
4 | 4 | const sourcePath = process.cwd();
|
5 | 5 | const outDir = join(sourcePath, "/dist/tmp/widgets/");
|
6 |
| -const widgetPackageJson = require(join(sourcePath, "package.json")); |
7 |
| -const widgetName = widgetPackageJson.widgetName; |
8 |
| -const widgetPackage = widgetPackageJson.packagePath; |
9 |
| -const outWidgetDir = join(widgetPackage.replace(/\./g, "/"), widgetName.toLowerCase()); |
10 |
| -const absoluteOutPackageDir = join(outDir, outWidgetDir); |
11 | 6 |
|
12 | 7 | module.exports = args => {
|
13 | 8 | const result = args.configDefaultConfig;
|
14 | 9 |
|
15 |
| - const localesDir = join(absoluteOutPackageDir, "locales"); |
| 10 | + const localesDir = join(outDir, "locales/"); |
16 | 11 | mkdir("-p", localesDir);
|
17 | 12 |
|
18 | 13 | const translationFiles = join(sourcePath, "dist/locales/**/*");
|
| 14 | + // copy everything under dist/locales to dist/tmp/widgets/locales for the widget mpk |
19 | 15 | cp("-r", translationFiles, localesDir);
|
| 16 | + // remove root level *.json locales files (duplicate with language specific files (e.g. en-US/*.json)) |
| 17 | + rm("-f", join(outDir, "locales/*.json"), localesDir); |
20 | 18 |
|
21 | 19 | return result;
|
22 | 20 | };
|
0 commit comments