tsbuild/ts/tsbuild.exports.ts

57 lines
1.7 KiB
TypeScript
Raw Permalink Normal View History

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[],
compilerOptionsArg: CompilerOptions = {},
2019-08-26 14:28:03 +00:00
argvArg?: any
2018-07-25 18:56:42 +00:00
): Promise<any[]> => {
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 = {},
cwdArg: string = process.cwd(),
2019-08-26 14:28:03 +00:00
argvArg?: any
2018-07-25 18:56:42 +00:00
) => {
2021-08-17 10:13:51 +00:00
let compiledFiles: plugins.smartfile.Smartfile[] = [];
for (const keyArg in globStringObjectArg) {
2019-08-26 14:28:03 +00:00
if (globStringObjectArg[keyArg]) {
console.log(
`TypeScript assignment: transpile from ${keyArg} to ${globStringObjectArg[keyArg]}`
);
const fileTreeArray = await plugins.smartfile.fs.listFileTree(cwdArg, keyArg);
2020-08-10 22:10:20 +00:00
const absoluteFilePathArray: string[] = plugins.smartpath.transform.toAbsolute(
fileTreeArray,
cwdArg
);
2020-08-10 22:10:20 +00:00
const 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;
};