Add check that there are samples for each language

This commit is contained in:
Alex Dima 2021-11-17 22:55:39 +01:00
parent f012a2aeee
commit 37f12e39a3
No known key found for this signature in database
GPG key ID: 39563C1504FDD0C9
11 changed files with 171 additions and 3 deletions

View file

@ -7,6 +7,7 @@
/** @typedef {import('../build/utils').IFile} IFile */
const glob = require('glob');
const path = require('path');
const fs = require('fs');
const cp = require('child_process');
@ -26,9 +27,51 @@ const MONACO_EDITOR_VERSION = (() => {
})();
removeDir(`../monaco-editor-website`);
checkSamples();
generateWebsite();
/**
* Check that there are samples for all available languages
*/
function checkSamples() {
let languages = glob
.sync('src/basic-languages/*/*.contribution.ts', { cwd: REPO_ROOT })
.map((f) => path.dirname(f))
.map((f) => f.substring('src/basic-languages/'.length));
languages.push('css');
languages.push('html');
languages.push('json');
languages.push('typescript');
// some languages have a different id than their folder
languages = languages.map((l) => {
switch (l) {
case 'coffee':
return 'coffeescript';
case 'protobuf':
return 'proto';
case 'solidity':
return 'sol';
case 'sophia':
return 'aes';
default:
return l;
}
});
let fail = false;
for (const language of languages) {
const expectedSamplePath = path.join(REPO_ROOT, `website/index/samples/sample.${language}.txt`);
if (!fs.existsSync(expectedSamplePath)) {
console.error(`Missing sample for ${language} at ${expectedSamplePath}`);
fail = true;
}
}
if (fail) {
process.exit(1);
}
}
/**
* @param {string} dataPath
* @param {string} contents