2018-07-25 18:56:42 +00:00
|
|
|
import * as plugins from './tsbuild.plugins';
|
|
|
|
import { compiler, CompilerOptions, mergeCompilerOptions } from './tsbuild.classes.compiler';
|
|
|
|
|
|
|
|
export * from './tsbuild.classes.compiler';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* compile am array of absolute file paths
|
|
|
|
*/
|
|
|
|
export let compileFileArray = (
|
|
|
|
fileStringArrayArg: string[],
|
2018-12-05 22:29:01 +00:00
|
|
|
compilerOptionsArg: CompilerOptions = {},
|
|
|
|
argvArg?: any,
|
2018-07-25 18:56:42 +00:00
|
|
|
): Promise<any[]> => {
|
2018-12-05 22:29:01 +00:00
|
|
|
return compiler(fileStringArrayArg, mergeCompilerOptions(compilerOptionsArg, argvArg), argvArg);
|
2018-07-25 18:56:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* compile advanced glob configurations
|
|
|
|
* @param globStringArrayArg a array of glob strings
|
|
|
|
* {
|
|
|
|
* './some/origin/folder/**\/*.ts': './some/destination/folder'
|
|
|
|
* }
|
|
|
|
*/
|
|
|
|
export let compileGlobStringObject = async (
|
|
|
|
globStringObjectArg: any,
|
|
|
|
tsOptionsArg: CompilerOptions = {},
|
2018-12-05 22:29:01 +00:00
|
|
|
cwdArg: string = process.cwd(),
|
|
|
|
argvArg?: any,
|
2018-07-25 18:56:42 +00:00
|
|
|
) => {
|
|
|
|
let compiledFiles = [];
|
2018-12-05 22:29:01 +00:00
|
|
|
for (const keyArg in globStringObjectArg) {
|
|
|
|
if(globStringObjectArg[keyArg]) {
|
|
|
|
console.log(
|
|
|
|
`TypeScript assignment: transpile from ${keyArg} to ${globStringObjectArg[keyArg]}`
|
|
|
|
);
|
|
|
|
const fileTreeArray = await plugins.smartfile.fs.listFileTree(cwdArg, keyArg);
|
|
|
|
let absoluteFilePathArray: string[] = plugins.smartpath.transform.toAbsolute(
|
|
|
|
fileTreeArray,
|
|
|
|
cwdArg
|
|
|
|
);
|
|
|
|
let destDir: string = plugins.smartpath.transform.toAbsolute(
|
|
|
|
globStringObjectArg[keyArg],
|
|
|
|
cwdArg
|
|
|
|
);
|
|
|
|
tsOptionsArg = {
|
|
|
|
...tsOptionsArg,
|
|
|
|
outDir: destDir
|
|
|
|
};
|
|
|
|
compiledFiles = compiledFiles.concat(
|
|
|
|
compiledFiles,
|
|
|
|
await compileFileArray(absoluteFilePathArray, tsOptionsArg, argvArg)
|
|
|
|
);
|
|
|
|
}
|
2018-07-25 18:56:42 +00:00
|
|
|
}
|
|
|
|
return compiledFiles;
|
|
|
|
};
|