fix(core): Replace ts-node with tsx for module handling

This commit is contained in:
2024-10-27 19:45:57 +01:00
parent c2e406964d
commit bec80e6862
7 changed files with 293 additions and 163 deletions

View File

@@ -22,21 +22,7 @@ export const runCli = async (pathArg?: string) => {
// thus when pathArg is specifed -> we only splice 2
pathArg ? process.argv.splice(0, 2) : process.argv.splice(0, 3); // this ensures transparent arguments for the child process
// lets setup things for execution
const smartshellInstance = new plugins.smartshell.Smartshell({
executor: 'bash',
});
const tsNodeLoaderPath = plugins.path.join(__dirname, 'loader.js');
// note: -> reduce on emtpy array does not work
// thus check needed before reducing the argv array
smartshellInstance.exec(
`node --loader ${tsNodeLoaderPath} ${absolutePathToTsFile} ${
process.argv.length > 0
? process.argv.reduce((prevArg, currentArg) => {
return prevArg + ' ' + currentArg;
})
: ''
}`,
);
const tsx = await import('tsx/esm/api');
const unregister = tsx.register();
await import(absolutePathToTsFile);
};