fix(tools): update challege formatting check
This commit is contained in:
		
				
					committed by
					
						
						mrugesh
					
				
			
			
				
	
			
			
			
						parent
						
							3ec1fe8ea7
						
					
				
				
					commit
					31f337f2bd
				
			@@ -41,6 +41,7 @@ function getSchemaForLang(lang) {
 | 
			
		||||
    ),
 | 
			
		||||
    guideUrl: Joi.string().uri({ scheme: 'https' }),
 | 
			
		||||
    videoUrl: Joi.string().allow(''),
 | 
			
		||||
    forumTopicId: Joi.number(),
 | 
			
		||||
    helpRoom: Joi.string(),
 | 
			
		||||
    id: Joi.objectId().required(),
 | 
			
		||||
    instructions: Joi.string().allow(''),
 | 
			
		||||
 
 | 
			
		||||
@@ -51,21 +51,26 @@ const challengeFrontmatterValidator = file => frontmatter => {
 | 
			
		||||
 | 
			
		||||
    `);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  const { videoUrl } = frontmatter;
 | 
			
		||||
 | 
			
		||||
  let validVideoUrl = false;
 | 
			
		||||
  if (isEmpty(videoUrl)) {
 | 
			
		||||
  if (!isEmpty(videoUrl) && !scrimbaUrlRE.test(videoUrl)) {
 | 
			
		||||
    validVideoUrl = true;
 | 
			
		||||
  } else {
 | 
			
		||||
    validVideoUrl = scrimbaUrlRE.test(videoUrl);
 | 
			
		||||
 | 
			
		||||
    if (!validVideoUrl) {
 | 
			
		||||
      console.log(`
 | 
			
		||||
  ${fullPath} contains an invalid videoUrl
 | 
			
		||||
`);
 | 
			
		||||
    }
 | 
			
		||||
    console.log(`
 | 
			
		||||
        ${fullPath} contains an invalid videoUrl
 | 
			
		||||
      `);
 | 
			
		||||
  }
 | 
			
		||||
  return hasRequiredProperties && validVideoUrl;
 | 
			
		||||
 | 
			
		||||
  const { forumTopicId } = frontmatter;
 | 
			
		||||
  let validForumTopicId = false;
 | 
			
		||||
  if (!isEmpty(forumTopicId) && !isNumber(forumTopicId)) {
 | 
			
		||||
    validForumTopicId = true;
 | 
			
		||||
    console.log(`
 | 
			
		||||
      ${fullPath} contains an invalid forumTopicId
 | 
			
		||||
    `);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return hasRequiredProperties && validVideoUrl && validForumTopicId;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
function isChallengeParseable(file) {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user