/
githubmirror
/
TypeScript
Обзор
Документация
Войти
/
githubmirror
/
TypeScript
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
scripts/build/projects.mjs
64 строки
2 KB
Jake Bailey
Update dprint, don't force multiline imports for imports of single name (#58038)
02 апр 2024, 20:58
Не верифицирован
02 апр 2024, 20:58
4cedfe4
Код
Авторство
О чём код?
import { resolve } from "path"; import { findUpRoot } from "./findUpDir.mjs"; import cmdLineOptions from "./options.mjs"; import { Debouncer, exec, } from "./utils.mjs"; class ProjectQueue { /** * @param {(projects: string[]) => Promise<any>} action */ constructor(action) { /** @type {string[] | undefined} */ this._projects = undefined; this._debouncer = new Debouncer(100, async () => { const projects = this._projects; if (projects) { this._projects = undefined; await action(projects); } }); } /** * @param {string} project */ enqueue(project) { if (!this._projects) this._projects = []; this._projects.push(project); return this._debouncer.enqueue(); } } const tscPath = resolve( findUpRoot(), cmdLineOptions.lkg ? "./lib/tsc.js" : cmdLineOptions.built ? "./built/local/tsc.js" : "./node_modules/typescript/lib/tsc.js", ); const execTsc = (/** @type {string[]} */ ...args) => exec(process.execPath, [tscPath, "-b", ...args], { hidePrompt: true }); const projectBuilder = new ProjectQueue(projects => execTsc(...(cmdLineOptions.bundle ? [] : ["--emitDeclarationOnly", "false"]), ...projects)); /** * @param {string} project */ export const buildProject = project => projectBuilder.enqueue(project); const projectCleaner = new ProjectQueue(projects => execTsc("--clean", ...projects)); /** * @param {string} project */ export const cleanProject = project => projectCleaner.enqueue(project); const projectWatcher = new ProjectQueue(projects => execTsc("--watch", "--preserveWatchOutput", ...projects)); /** * @param {string} project */ export const watchProject = project => projectWatcher.enqueue(project);