fix(guide-ci): Reimplement throwing to the CI script
This commit is contained in:
@ -15,19 +15,20 @@ const allowedLangDirNames = [
|
|||||||
|
|
||||||
function checkDirName(dirName, fullPath) {
|
function checkDirName(dirName, fullPath) {
|
||||||
if (dirName.replace(/(\s|\_)/, '') !== dirName) {
|
if (dirName.replace(/(\s|\_)/, '') !== dirName) {
|
||||||
const newDirName = dirName.replace(/\s/g, '-');
|
throw new Error(`
|
||||||
fs.renameSync(fullPath, fullPath.replace(dirName, newDirName));
|
Invalid character found in '${dirName}', please use '-' for spaces
|
||||||
// throw new Error(
|
|
||||||
// `Invalid character found in a folder named '${dirName}', please use '-' for spaces
|
Found in:
|
||||||
// ${fullPath}
|
${fullPath}
|
||||||
// `
|
`);
|
||||||
// );
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (dirName.toLowerCase() !== dirName) {
|
if (dirName.toLowerCase() !== dirName) {
|
||||||
const newPath = fullPath.replace(dirName, dirName.toLowerCase());
|
throw new Error(`
|
||||||
console.log(`renaming ${dirName} to ${dirName.toLowerCase()}`);
|
Upper case characters found in ${dirName}, all folder names must be lower case
|
||||||
fs.renameSync(fullPath, newPath);
|
|
||||||
|
Found in :
|
||||||
|
${fullPath}
|
||||||
|
`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,8 +36,10 @@ function checkFileName(fileName, fullPath) {
|
|||||||
if (fileName !== 'index.md') {
|
if (fileName !== 'index.md') {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`${fileName} is not a valid file name, please use 'index.md'
|
`${fileName} is not a valid file name, please use 'index.md'
|
||||||
${fullPath}
|
|
||||||
`
|
Found in:
|
||||||
|
${fullPath}
|
||||||
|
`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user