-
Notifications
You must be signed in to change notification settings - Fork 6
/
migrate-apps.js
38 lines (32 loc) · 971 Bytes
/
migrate-apps.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const fs = require("fs");
const path = require("path");
const inputDirectory = "./content/apps";
const outputDirectory = "./content/converted-apps";
console.log("converting apps....");
function convertApps() {
const fileNames = fs.readdirSync(inputDirectory);
const allPostsData = fileNames
.filter((it) => it.endsWith(".json"))
.map((fileName) => {
// Read markdown file as string
const fullPath = path.join(inputDirectory, fileName);
const fileContents = fs.readFileSync(fullPath, "utf8");
const outputPath = path.join(outputDirectory, fileName);
const app = JSON.parse(fileContents);
/// customize the app
fs.writeFile(
outputPath,
JSON.stringify({
...app,
}),
(error) => {
if (error) throw error;
}
);
});
}
fs.mkdir(outputDirectory, { recursive: true }, (err) => {
if (err) throw err;
convertApps();
console.log("Completed");
});