check-samples.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*---------------------------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Licensed under the MIT License. See License.txt in the project root for license information.
  4. *--------------------------------------------------------------------------------------------*/
  5. import * as fs from 'fs';
  6. import * as glob from 'glob';
  7. import * as path from 'path';
  8. import { REPO_ROOT } from './utils';
  9. checkEveryMonacoLanguageHasASample();
  10. function checkEveryMonacoLanguageHasASample() {
  11. let languages = glob
  12. .sync('src/basic-languages/*/*.contribution.ts', { cwd: REPO_ROOT })
  13. .map((f) => path.dirname(f))
  14. .map((f) => f.substring('src/basic-languages/'.length));
  15. languages.push('css');
  16. languages.push('html');
  17. languages.push('json');
  18. languages.push('typescript');
  19. // some languages have a different id than their folder
  20. languages = languages.map((l) => {
  21. switch (l) {
  22. case 'coffee':
  23. return 'coffeescript';
  24. case 'protobuf':
  25. return 'proto';
  26. case 'solidity':
  27. return 'sol';
  28. case 'sophia':
  29. return 'aes';
  30. default:
  31. return l;
  32. }
  33. });
  34. let fail = false;
  35. for (const language of languages) {
  36. const expectedSamplePath = path.join(
  37. REPO_ROOT,
  38. `website/src/website/data/home-samples/sample.${language}.txt`
  39. );
  40. if (!fs.existsSync(expectedSamplePath)) {
  41. console.error(`Missing sample for ${language} at ${expectedSamplePath}`);
  42. fail = true;
  43. }
  44. }
  45. if (fail) {
  46. process.exit(1);
  47. }
  48. }