import * as sources from "./Source"; import * as file from "./file"; import * as path from "path"; import {repeat} from "./string-repeat"; export function generateSourceExports (arr : sources.Source[]) { for (let src of arr) { const resultLines : string[] = []; /* We have to export, + check + is + assert + promise */ const nestCount = src.name.split("/").length; const unnest = repeat("../", nestCount); const checkPath = src.generated ? `${unnest}sync/check/${src.name}` : `${unnest}../sync/check/${src.name}`; const isPath = `${unnest}sync/is/${src.name}`; const assertPath = `${unnest}sync/assert/${src.name}`; const promisePath = `${unnest}promise/${src.name}`; resultLines.push(`export * from "${checkPath}";`); resultLines.push(`export * from "${isPath}";`); resultLines.push(`export * from "${assertPath}";`); resultLines.push(`export * from "${promisePath}";`); const result = resultLines.join("\n"); const writePath = path.resolve(`${__dirname}/../main/generated/export/${src.name}.ts`); file.writeSync(writePath, result); } } export function generateAllInOneExport (arr : sources.Source[]) { /* We want to export all sources, and non-generated code */ const resultLines : string[] = []; for (let src of arr) { resultLines.push(`import * as imported${src.pascal} from "./export/${src.name}";`); } resultLines.push("") for (let src of arr) { resultLines.push(`export {imported${src.pascal} as ${src.pascal}};`); } const result = resultLines.join("\n"); const writePath = path.resolve(`${__dirname}/../main/generated/export.ts`); file.writeSync(writePath, result); } export function generateExports (arr : sources.Source[]) { generateSourceExports(arr); generateAllInOneExport(arr); }