[fix][website] fix script for invalid tab check
@@ -19,15 +19,16 @@ function fixMd(filepath) {
/^[ ]+<!--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 @@ function fixMd(filepath) {
} else {
fs.copyFileSync(path.join(__dirname, "../../docs", filename), filepath);
}
+ console.log("******* [Fixed]Invalid tab fixed for ", filepath);
}
}
