Skip to content

Commit f37e88f

Browse files
committed
Remove some dead build code
1 parent 106d58a commit f37e88f

File tree

1 file changed

+0
-85
lines changed

1 file changed

+0
-85
lines changed

scripts/build/utils.js

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
const fs = require("fs");
88
const path = require("path");
99
const log = require("fancy-log");
10-
const mkdirp = require("mkdirp");
1110
const del = require("del");
1211
const File = require("vinyl");
1312
const ts = require("../../lib/typescript");
@@ -225,90 +224,6 @@ function getDirSize(root) {
225224
}
226225
exports.getDirSize = getDirSize;
227226

228-
/**
229-
* Flattens a project with project references into a single project.
230-
* @param {string} projectSpec The path to a tsconfig.json file or its containing directory.
231-
* @param {string} flattenedProjectSpec The output path for the flattened tsconfig.json file.
232-
* @param {FlattenOptions} [options] Options used to flatten a project hierarchy.
233-
*
234-
* @typedef FlattenOptions
235-
* @property {string} [cwd] The path to use for the current working directory. Defaults to `process.cwd()`.
236-
* @property {import("../../lib/typescript").CompilerOptions} [compilerOptions] Compiler option overrides.
237-
* @property {boolean} [force] Forces creation of the output project.
238-
* @property {string[]} [exclude] Files to exclude (relative to `cwd`)
239-
*/
240-
function flatten(projectSpec, flattenedProjectSpec, options = {}) {
241-
const cwd = normalizeSlashes(options.cwd ? path.resolve(options.cwd) : process.cwd());
242-
const files = [];
243-
const resolvedOutputSpec = path.resolve(cwd, flattenedProjectSpec);
244-
const resolvedOutputDirectory = path.dirname(resolvedOutputSpec);
245-
const resolvedProjectSpec = resolveProjectSpec(projectSpec, cwd, /*referrer*/ undefined);
246-
const project = readJson(resolvedProjectSpec);
247-
const skipProjects = /**@type {Set<string>}*/(new Set());
248-
const skipFiles = new Set(options && options.exclude && options.exclude.map(file => normalizeSlashes(path.resolve(cwd, file))));
249-
recur(resolvedProjectSpec, project);
250-
251-
if (options.force || needsUpdate(files, resolvedOutputSpec)) {
252-
const config = {
253-
extends: normalizeSlashes(path.relative(resolvedOutputDirectory, resolvedProjectSpec)),
254-
compilerOptions: options.compilerOptions || {},
255-
files: files.map(file => normalizeSlashes(path.relative(resolvedOutputDirectory, file)))
256-
};
257-
mkdirp.sync(resolvedOutputDirectory);
258-
fs.writeFileSync(resolvedOutputSpec, JSON.stringify(config, undefined, 2), "utf8");
259-
}
260-
261-
/**
262-
* @param {string} projectSpec
263-
* @param {object} project
264-
*/
265-
function recur(projectSpec, project) {
266-
if (skipProjects.has(projectSpec)) return;
267-
skipProjects.add(project);
268-
if (project.references) {
269-
for (const ref of project.references) {
270-
const referencedSpec = resolveProjectSpec(ref.path, cwd, projectSpec);
271-
const referencedProject = readJson(referencedSpec);
272-
recur(referencedSpec, referencedProject);
273-
}
274-
}
275-
if (project.include) {
276-
throw new Error("Flattened project may not have an 'include' list.");
277-
}
278-
if (!project.files) {
279-
throw new Error("Flattened project must have an explicit 'files' list.");
280-
}
281-
const projectDirectory = path.dirname(projectSpec);
282-
for (let file of project.files) {
283-
file = normalizeSlashes(path.resolve(projectDirectory, file));
284-
if (skipFiles.has(file)) continue;
285-
skipFiles.add(file);
286-
files.push(file);
287-
}
288-
}
289-
}
290-
exports.flatten = flatten;
291-
292-
/**
293-
* @param {string} file
294-
*/
295-
function normalizeSlashes(file) {
296-
return file.replace(/\\/g, "/");
297-
}
298-
299-
/**
300-
* @param {string} projectSpec
301-
* @param {string} cwd
302-
* @param {string | undefined} referrer
303-
* @returns {string}
304-
*/
305-
function resolveProjectSpec(projectSpec, cwd, referrer) {
306-
const projectPath = normalizeSlashes(path.resolve(cwd, referrer ? path.dirname(referrer) : "", projectSpec));
307-
const stats = fs.statSync(projectPath);
308-
if (stats.isFile()) return normalizeSlashes(projectPath);
309-
return normalizeSlashes(path.resolve(cwd, projectPath, "tsconfig.json"));
310-
}
311-
312227
/**
313228
* @param {string | ((file: File) => string) | { cwd?: string }} [dest]
314229
* @param {{ cwd?: string }} [opts]

0 commit comments

Comments
 (0)