forked from microsoft/FluidFramework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
local-api-rollup.js
50 lines (43 loc) · 1.36 KB
/
local-api-rollup.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
39
40
41
42
43
44
45
46
47
48
49
50
/*!
* Copyright (c) Microsoft Corporation and contributors. All rights reserved.
* Licensed under the MIT License.
*/
/*
* Copies local _api-extractor-temp/doc-models to docs/doc-models/local
* This is for running local doc builds to see api changes immediately in the docs.
*/
import fs from "fs-extra";
import path from "path";
const sourceDir = "../_api-extractor-temp/doc-models";
const destinationDir = "./_doc-models/local";
async function copyDocModels(files) {
// Create the destination directory if it doesn't exist
if (!fs.existsSync(destinationDir)) {
fs.mkdirSync(destinationDir, { recursive: true });
} else {
// Delete existing documentation output
await fs.ensureDir(destinationDir);
await fs.emptyDir(destinationDir);
}
// Copy each file from the source directory to the destination directory
files.forEach((file) => {
const sourcePath = path.join(sourceDir, file);
const destinationPath = path.join(destinationDir, file);
fs.copyFile(sourcePath, destinationPath, (err) => {
if (err) {
console.error(`Error copying file ${file}:`, err);
} else {
console.log(`Copied file ${file} to ${destinationDir}`);
}
});
});
}
// Get the list of files in the source directory
fs.readdir(sourceDir, (err, files) => {
if (err) {
console.error("Error reading source directory:", err);
return;
} else {
copyDocModels(files);
}
});