Skip to content

Commit 749f254

Browse files
(gh-actions trigger) fix copy docs ci
1 parent b27374c commit 749f254

File tree

3 files changed

+8
-159
lines changed

3 files changed

+8
-159
lines changed

docs/flags/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# This .gitignore file will be included in copy ci execution.
22
# Only add targets that shouuld not be included in final docs deployment.
33
__**__.md
4+
*
45
README.md

docs/flags/index.md

Lines changed: 0 additions & 115 deletions
This file was deleted.
Lines changed: 7 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,14 @@
1-
const fs = require("fs");
21
const path = require("path");
2+
const fse = require("fs-extra");
33

44
const origin = path.join(__dirname, "../../packages/support-flags/docs");
55
const target = path.join(__dirname, "../../docs/flags");
66

7-
/**
8-
* from https://stackoverflow.com/a/26038979/5463235
9-
*/
10-
function copyFileSync(source, target) {
11-
var targetFile = target;
12-
13-
// If target is a directory, a new file with the same name will be created
14-
if (fs.existsSync(target)) {
15-
if (fs.lstatSync(target).isDirectory()) {
16-
targetFile = path.join(target, path.basename(source));
17-
}
18-
}
19-
20-
fs.writeFileSync(targetFile, fs.readFileSync(source));
21-
}
22-
23-
/**
24-
* from https://stackoverflow.com/a/26038979/5463235
25-
*/
26-
function copyFolderRecursiveSync(source, target, custom_name) {
27-
var files = [];
28-
29-
// Check if folder needs to be created or integrated
30-
var targetFolder = path.join(target, custom_name);
31-
if (!fs.existsSync(targetFolder)) {
32-
throw `target folder does not exist - ${targetFolder}`;
33-
}
34-
35-
// Copy
36-
if (fs.lstatSync(source).isDirectory()) {
37-
files = fs.readdirSync(source);
38-
files.forEach(function (file) {
39-
var curSource = path.join(source, file);
40-
if (fs.lstatSync(curSource).isDirectory()) {
41-
copyFolderRecursiveSync(curSource, targetFolder);
42-
} else {
43-
copyFileSync(curSource, targetFolder);
44-
}
45-
});
46-
}
47-
}
48-
497
if (require.main === module) {
50-
copyFolderRecursiveSync(origin, target, ".");
8+
fse.copySync(origin, target, { overwrite: true }, function (err) {
9+
if (err) {
10+
console.error(err);
11+
} else {
12+
}
13+
});
5114
}

0 commit comments

Comments
 (0)