diff --git a/.circleci/config.yml b/.circleci/config.yml index a1073092..0718a25b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -64,6 +64,16 @@ jobs: command: | cd scripts/ && npm install && npm run yaml-content-validate + swc-yaml-config-content: + <<: *defaults + steps: + - checkout + - run: + name: Check folder structure + shell: /bin/sh + command: | + cd scripts/ && npm install && npm run validate-dirs + deploy-gh-pages: <<: *defaults steps: diff --git a/scripts/dir_structure.js b/scripts/dir_structure.js new file mode 100644 index 00000000..99805bd8 --- /dev/null +++ b/scripts/dir_structure.js @@ -0,0 +1,35 @@ +const fs = require('fs'); +const path = require('path'); + +const walkSync = (dir, filelist=[]) => { + fs.readdirSync(dir).forEach((file) => { + if(fs.statSync(path.join(dir, file)).isDirectory()) { + filelist = walkSync(path.join(dir, file), filelist) + } else { + filelist = filelist.concat(path.join(dir, file)); + } + }); + return filelist; +}; + +let hasError = false; + +const files = walkSync('../test_cases'); + +files.map(file => { + const splitedPath = file.split('/'); + + const [filepath, folder, ...rest] = splitedPath.reverse(); + const [filename, ...restels] = filepath.split('.'); + + if (folder !== filename) { + hasError = true; + console.log(`Path is wrong: ${file}`); + } +}); + +if (hasError) { + process.exit(1); +} else { + process.exit(0); +} \ No newline at end of file diff --git a/scripts/package.json b/scripts/package.json index 2a238079..5f362464 100644 --- a/scripts/package.json +++ b/scripts/package.json @@ -17,7 +17,8 @@ "yaml-schema-lint": "node yaml_schema_validate.js", "yaml-content-validate": "node yaml_validate.js", "markdown-validate": "node update_swc.js markdown-validate", - "update-swc": "node update_swc.js > ../export/swc-definition.json" + "update-swc": "node update_swc.js > ../export/swc-definition.json", + "validate-dirs": "node dir_structure.js" }, "author": "", "license": "ISC"