Skip to content

Commit 2abf881

Browse files
authored
Merge pull request #1243 from fturmel/PR/upgrade-deps-and-minor-improvements
Upgrade deps (Gatsby 5.11) and minor improvements
2 parents ae6796e + f205889 commit 2abf881

File tree

5 files changed

+4825
-3202
lines changed

5 files changed

+4825
-3202
lines changed

node-scripts/tags-transforms.js

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,38 @@
1-
const { globSync } = require('glob');
1+
const { glob } = require('glob');
22
const isEqual = require('lodash/isEqual');
33
const prettier = require('prettier');
4-
const { readFileSync, writeFileSync } = require('fs');
4+
const { readFile, writeFile } = require('fs/promises');
55
const { memoTagsCleanup } = require('./utils');
66
const { wordReplacements, tagTransforms } = require('./tags-transforms.json');
77

88
const tagsCleanup = memoTagsCleanup(wordReplacements, tagTransforms);
9-
const paths = globSync('content/videos/**/index.json');
10-
let count = 0;
119

12-
for (let path of paths) {
13-
const raw = readFileSync(path);
14-
const o = JSON.parse(raw);
10+
(async () => {
11+
const paths = await glob('content/videos/**/index.json');
12+
let count = 0;
1513

16-
const languages = tagsCleanup(o.languages);
17-
const topics = tagsCleanup(o.topics);
14+
for (const path of paths) {
15+
const raw = await readFile(path);
16+
const o = JSON.parse(raw);
1817

19-
if (!isEqual(languages, o.languages) || !isEqual(topics, o.topics)) {
20-
o.languages = languages;
21-
o.topics = topics;
18+
const languages = tagsCleanup(o.languages);
19+
const topics = tagsCleanup(o.topics);
2220

23-
const udpatedSource = prettier.format(JSON.stringify(o), {
24-
parser: 'json'
25-
});
21+
if (!isEqual(languages, o.languages) || !isEqual(topics, o.topics)) {
22+
o.languages = languages;
23+
o.topics = topics;
2624

27-
writeFileSync(path, udpatedSource);
25+
const udpatedSource = await prettier.format(JSON.stringify(o), {
26+
parser: 'json'
27+
});
2828

29-
count++;
29+
await writeFile(path, udpatedSource);
30+
31+
count++;
32+
}
3033
}
31-
}
3234

33-
console.log(
34-
`${count} of ${paths.length} video JSON files were modified to transform language and topic tags`
35-
);
35+
console.log(
36+
`${count} of ${paths.length} video JSON files were modified to transform language and topic tags`
37+
);
38+
})();

0 commit comments

Comments
 (0)