UNPKG

turbo-gulp

Version:

Gulp tasks to boost high-quality projects.

52 lines (51 loc) 1.79 kB
/** * This module defines the general configuration of the project. * * @module project */ /** (Placeholder comment, see christopherthielen/typedoc-plugin-external-module-name#6) */ import { posix as posixPath, resolve as resolveSysPath } from "path"; import { DEFAULT_PROJECT_TS_OPTIONS } from "./options/typescript"; /** * Preconfigured project configuration. * It uses process.cwd() as the root and assumes a standard project structure. */ export const DEFAULT_PROJECT = { root: process.cwd(), packageJson: "package.json", buildDir: "build", distDir: "dist", srcDir: "src", tslint: { tslintJson: "tslint.json", }, typescript: DEFAULT_PROJECT_TS_OPTIONS, }; /** * Normalizes a system-dependent path to a POSIX path. * * @param path System-dependent path. * @return Normalized POSIX path. */ export function toPosix(path) { return path.replace(/\\/g, "/"); } /** * Resolve absolute paths for project locations. * This creates a shallow copy of the project configuration. * If the project was already resolved, it will compute the resolved values again anyway so you it * guarantees that the result is coherent. * * @param project Project configuration. * @return Project configuration with resolved paths. */ export function resolveProject(project) { const absRoot = toPosix(resolveSysPath(project.root)); const absPackageJson = toPosix(resolveSysPath(project.packageJson)); const absSrcDir = posixPath.join(absRoot, project.srcDir); const absBuildDir = posixPath.join(absRoot, project.buildDir); const absDistDir = posixPath.join(absRoot, project.distDir); return Object.assign({}, project, { absRoot, absPackageJson, absSrcDir, absBuildDir, absDistDir }); } export function registerProjectTasks() { }