@discord/intl-loader-core 0.21.1-canary.d6da0a2 → 0.22.0-rc.0
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/package.json +2 -2
- package/src/watcher.js +9 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@discord/intl-loader-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0-rc.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Core utilities for writing loaders and transformers using @discord/intl",
|
|
6
6
|
"author": "Jon Egeland",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"chokidar": "^3.6.0",
|
|
30
30
|
"debug": "^4.3.6",
|
|
31
|
-
"@discord/intl-message-database": "0.
|
|
31
|
+
"@discord/intl-message-database": "0.22.0-rc.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/debug": "^4.1.12",
|
package/src/watcher.js
CHANGED
|
@@ -49,7 +49,7 @@ const DEFAULT_LOCALE = 'en-US';
|
|
|
49
49
|
*/
|
|
50
50
|
async function watchMessagesFiles(
|
|
51
51
|
watchedFolders,
|
|
52
|
-
{ ignore = [], skipInitial = false, once = true } = {}
|
|
52
|
+
{ ignore = [], skipInitial = false, once = true } = {}
|
|
53
53
|
) {
|
|
54
54
|
debug('Pre-initializing database with all discoverable messages files');
|
|
55
55
|
const files = findAllMessagesFiles(watchedFolders);
|
|
@@ -75,7 +75,7 @@ async function watchMessagesFiles(
|
|
|
75
75
|
|
|
76
76
|
const ignoredPatterns = ignore.concat(ALWAYS_IGNORE_PATTERNS);
|
|
77
77
|
const globs = watchedFolders.flatMap((folder) =>
|
|
78
|
-
MESSAGES_FILE_PATTERNS.map((pattern) => path.join(folder, pattern))
|
|
78
|
+
MESSAGES_FILE_PATTERNS.map((pattern) => path.join(folder, pattern))
|
|
79
79
|
);
|
|
80
80
|
|
|
81
81
|
debug(`Initializing watch for patterns:\n- ${globs.join('\n- ')}`);
|
|
@@ -86,12 +86,15 @@ async function watchMessagesFiles(
|
|
|
86
86
|
});
|
|
87
87
|
|
|
88
88
|
watcher.on('all', (event, path) => {
|
|
89
|
+
const files = filterAllMessagesFiles([path]);
|
|
90
|
+
if (files.length === 0) return;
|
|
91
|
+
|
|
89
92
|
// Process the file that changed first, then reprocess all of the queued files from previous
|
|
90
93
|
// failures to hopefully get them to process successfully again.
|
|
91
|
-
const [result] = processAllMessagesFiles(
|
|
94
|
+
const [result] = processAllMessagesFiles(files);
|
|
92
95
|
const failed = result.errors.length > 0 ? [result.fileKey] : [];
|
|
93
96
|
const secondResult = processAllMessagesFiles(
|
|
94
|
-
filterAllMessagesFiles([...reprocessQueue, ...failed])
|
|
97
|
+
filterAllMessagesFiles([...reprocessQueue, ...failed])
|
|
95
98
|
);
|
|
96
99
|
// For any files that are still failing, keep them in the queue for next time.
|
|
97
100
|
const secondFailures = secondResult
|
|
@@ -141,7 +144,7 @@ async function generateMessageTypes(watcher) {
|
|
|
141
144
|
*/
|
|
142
145
|
async function precompileMessageDefinitionsFiles(
|
|
143
146
|
watcher,
|
|
144
|
-
{ assetExtension = 'json', precompileOptions = {} } = {}
|
|
147
|
+
{ assetExtension = 'json', precompileOptions = {} } = {}
|
|
145
148
|
) {
|
|
146
149
|
watcher.on('all', (_, filePath) => {
|
|
147
150
|
const { format = IntlCompiledMessageFormat.KeylessJson, bundleSecrets = false } =
|
|
@@ -153,7 +156,7 @@ async function precompileMessageDefinitionsFiles(
|
|
|
153
156
|
// Convert the file name from `.messages.js` to `.compiled.messages.jsona` for output.
|
|
154
157
|
const outputPath = filePath.replace(
|
|
155
158
|
/\.messages\.js$/,
|
|
156
|
-
`.compiled.messages.${assetExtension}
|
|
159
|
+
`.compiled.messages.${assetExtension}`
|
|
157
160
|
);
|
|
158
161
|
const result = processDefinitionsFile(filePath);
|
|
159
162
|
if (!result.succeeded) {
|