1
0

dts.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. const path = require('path');
  6. const fs = require('fs');
  7. const REPO_ROOT = path.join(__dirname, '../');
  8. const SRC_PATH = path.join(REPO_ROOT, 'out/amd/monaco.contribution.d.ts');
  9. const DST_PATH = path.join(REPO_ROOT, 'monaco.d.ts');
  10. const lines = fs
  11. .readFileSync(SRC_PATH)
  12. .toString()
  13. .split(/\r\n|\r|\n/);
  14. let result = [
  15. `/*---------------------------------------------------------------------------------------------`,
  16. ` * Copyright (c) Microsoft Corporation. All rights reserved.`,
  17. ` * Licensed under the MIT License. See License.txt in the project root for license information.`,
  18. ` *--------------------------------------------------------------------------------------------*/`,
  19. ``,
  20. `/// <reference path="node_modules/monaco-editor-core/monaco.d.ts" />`,
  21. ``,
  22. `declare namespace monaco.languages.json {`
  23. ];
  24. for (let line of lines) {
  25. if (/^import/.test(line)) {
  26. continue;
  27. }
  28. line = line.replace(/ /g, '\t');
  29. line = line.replace(/declare /g, '');
  30. if (line.length > 0) {
  31. line = `\t${line}`;
  32. result.push(line);
  33. }
  34. }
  35. result.push(`}`);
  36. result.push(``);
  37. fs.writeFileSync(DST_PATH, result.join('\n'));