diff --git a/build/importEditorWebpackPlugin.js b/build/importEditorWebpackPlugin.js index 3e598fee..0f880db5 100644 --- a/build/importEditorWebpackPlugin.js +++ b/build/importEditorWebpackPlugin.js @@ -3,11 +3,12 @@ * Licensed under the MIT License. See LICENSE in the project root for license information. *--------------------------------------------------------------------------------------------*/ +//@ts-check + const glob = require('glob'); const path = require('path'); const fs = require('fs'); - -const REPO_ROOT = path.join(__dirname, '..'); +const { REPO_ROOT } = require('./utils'); const customFeatureLabels = { 'vs/editor/browser/controller/coreCommands': 'coreCommands', @@ -187,6 +188,10 @@ export type EditorLanguage = ${result.map((el) => `'${el.label}'`).join(' | ')}; ); } +/** + * @tyoe {string} a + * @tyoe {string} b + */ function strcmp(a, b) { if (a < b) { return -1; @@ -197,9 +202,6 @@ function strcmp(a, b) { return 0; } -/** - * @returns { string[] } - */ function generateFeatures() { const skipImports = [ 'vs/editor/browser/widget/codeEditorWidget', @@ -212,6 +214,7 @@ function generateFeatures() { 'vs/editor/contrib/gotoSymbol/documentSymbols' ]; + /** @type {string[]} */ let features = []; const files = fs.readFileSync(path.join(REPO_ROOT, 'release/esm/vs/editor/edcore.main.js')).toString() + @@ -226,6 +229,7 @@ function generateFeatures() { } }); + /** @type {{label:string;entry:any;}[]} */ let result = features.map((feature) => { return { label: customFeatureLabels[feature] || path.basename(path.dirname(feature)), diff --git a/build/importTypescript.js b/build/importTypescript.js index 3dcb3551..b1a8847e 100644 --- a/build/importTypescript.js +++ b/build/importTypescript.js @@ -3,16 +3,18 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ +//@ts-check + const path = require('path'); const fs = require('fs'); const child_process = require('child_process'); +const { REPO_ROOT } = require('./utils'); const generatedNote = `// // **NOTE**: Do not edit directly! This file is generated using \`npm run import-typescript\` // `; -const REPO_ROOT = path.join(__dirname, '../'); const TYPESCRIPT_LIB_SOURCE = path.join(REPO_ROOT, 'node_modules/typescript/lib'); const TYPESCRIPT_LIB_DESTINATION = path.join(REPO_ROOT, 'src/typescript/lib'); diff --git a/build/npm/installAll.js b/build/npm/installAll.js index ca015aeb..adb0dff7 100644 --- a/build/npm/installAll.js +++ b/build/npm/installAll.js @@ -10,8 +10,7 @@ const path = require('path'); const fs = require('fs'); const cp = require('child_process'); const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm'; - -const REPO_ROOT = path.join(__dirname, '../../'); +const { REPO_ROOT } = require('../utils'); const files = glob.sync('**/package.json', { cwd: REPO_ROOT, diff --git a/build/npm/removeAll.js b/build/npm/removeAll.js index 72330798..f67f3f82 100644 --- a/build/npm/removeAll.js +++ b/build/npm/removeAll.js @@ -8,8 +8,7 @@ const glob = require('glob'); const path = require('path'); const fs = require('fs'); - -const REPO_ROOT = path.join(__dirname, '../../'); +const { REPO_ROOT } = require('../utils'); const files = glob.sync('**/package-lock.json', { cwd: REPO_ROOT, diff --git a/build/utils.js b/build/utils.js index b6c3f1c3..d7bd4d04 100644 --- a/build/utils.js +++ b/build/utils.js @@ -9,9 +9,11 @@ const fs = require('fs'); const path = require('path'); const cp = require('child_process'); const esbuild = require('esbuild'); +/** @type {any} */ const alias = require('esbuild-plugin-alias'); -const REPO_ROOT = path.join(__dirname, '..'); +const REPO_ROOT = path.join(__dirname, '../'); +exports.REPO_ROOT = REPO_ROOT; /** * @param {string} dirname