[fix][website] fix script for invalid tab check (#15187)
diff --git a/site2/website/scripts/fix-tab.js b/site2/website/scripts/fix-tab.js
index 73b27f0..7252a00 100644
--- a/site2/website/scripts/fix-tab.js
+++ b/site2/website/scripts/fix-tab.js
@@ -19,15 +19,16 @@
/^[ ]+<!--DOCUSAURUS_CODE_TABS-->/gm.test(data) ||
/<!--DOCUSAURUS_CODE_TABS-->\s+([^<!--]+)$/gm.test(data)
) {
- //(fr|ko|pt-PT|zh-CN|zh-TW)
- //(version-(\d\.?)+)
- let locale = /(fr|ko|pt-PT|zh-CN|zh-TW)/.exec(filepath)[1];
+ console.log("------- [Exists]Invalid tab exists in", filepath);
let filename = filepath.substr(filepath.lastIndexOf("/") + 1);
- let version = /(version-(\d\.?)+)/.exec(filepath);
- if (version) {
+ let locale = /\/(fr|ko|pt-PT|zh-CN|zh-TW)\//.exec(filepath);
+ if (locale && locale.length > 1) {
+ locale = locale[1];
+ }
+ let version = /\/(version-(\d\.?)+(-incubating)?)\//.exec(filepath);
+ if (version && version.length > 1) {
version = version[1];
}
- console.log(filepath, locale, version, filename);
if (version) {
fs.copyFileSync(
path.join(__dirname, "../versioned_docs/", version, filename),
@@ -36,6 +37,7 @@
} else {
fs.copyFileSync(path.join(__dirname, "../../docs", filename), filepath);
}
+ console.log("******* [Fixed]Invalid tab fixed for ", filepath);
}
}