turbo-gulp
Version:
Gulp tasks to boost high-quality projects.
22 lines (21 loc) • 959 B
JavaScript
import { posix as posixPath } from "path";
import { writeJsonFile } from "../utils/project";
import { resolveTsLocations } from "./_typescript";
export function getTsconfigJsonTask(options) {
const resolved = resolveTsLocations(options);
let typeRoots = [];
if (resolved.typeRoots !== undefined) {
typeRoots = resolved.typeRoots.map((abs) => posixPath.relative(resolved.tsconfigJsonDir, abs));
}
const tscOptions = Object.assign({}, options.tscOptions, { rootDir: posixPath.relative(resolved.tsconfigJsonDir, resolved.rootDir), outDir: posixPath.relative(resolved.tsconfigJsonDir, resolved.outDir), typeRoots });
const tsconfigData = {
compilerOptions: tscOptions,
include: resolved.relInclude,
exclude: resolved.relExclude,
};
const task = async function () {
return writeJsonFile(resolved.tsconfigJson, tsconfigData);
};
task.displayName = "_tsconfig.json";
return task;
}