From d76dfa6be50b07b91ace473949c1ef2dec5194bf Mon Sep 17 00:00:00 2001 From: Adriel Bento Date: Thu, 2 Feb 2023 14:22:38 -0300 Subject: [PATCH] =?UTF-8?q?[LEARN-7454]=20Ignora=20arquivos=20que=20n?= =?UTF-8?q?=C3=A3o=20sejam=20markdown=20(#16)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: ignora arquivos que nao sao markdown * chore: gera o dist --- dist/index.js | 7 +++++-- src/test/integration.test.js | 8 ++++++++ src/validate.js | 7 +++++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/dist/index.js b/dist/index.js index 6fbb3bb..cc49203 100644 --- a/dist/index.js +++ b/dist/index.js @@ -9623,8 +9623,7 @@ async function validate(){ function getFiles() { return process.env.INPUT_FILES .split(' ') - .filter(file => !file.includes('.yml')) - .filter(file => !file.includes('.xml')) + .filter(isMarkdown) .filter(file => !invalidFiles.includes(file)) .filter(isNumericPath) } @@ -9718,6 +9717,10 @@ function isNumericPath(path) { return !isNaN(name) } +function isMarkdown(path){ + return path.includes('.md') +} + module.exports = validate /***/ }), diff --git a/src/test/integration.test.js b/src/test/integration.test.js index 7ae6458..f610267 100644 --- a/src/test/integration.test.js +++ b/src/test/integration.test.js @@ -86,4 +86,12 @@ describe('Test quiz validator', () =>{ const result = await validate() expect(result).toEqual(false) }) + + test('must return false when no files is markdown', async () => { + const files = ['test.js', 'test.yml', 'test.html', 'test.md', 'metadados.md', '.cspell.json'] + process.env.INPUT_FILES = files.concat(' ') + + const result = await validate() + expect(result).toEqual(false) + }) }) \ No newline at end of file diff --git a/src/validate.js b/src/validate.js index e17b0d2..9d329f0 100644 --- a/src/validate.js +++ b/src/validate.js @@ -61,8 +61,7 @@ async function validate(){ function getFiles() { return process.env.INPUT_FILES .split(' ') - .filter(file => !file.includes('.yml')) - .filter(file => !file.includes('.xml')) + .filter(isMarkdown) .filter(file => !invalidFiles.includes(file)) .filter(isNumericPath) } @@ -156,4 +155,8 @@ function isNumericPath(path) { return !isNaN(name) } +function isMarkdown(path){ + return path.includes('.md') +} + module.exports = validate \ No newline at end of file