From 1113251aea5778ccfad1c4ffbdfa3107bc8fa659 Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Sat, 12 Mar 2022 21:52:14 +0100 Subject: [PATCH] fix(core): update --- ts/index.ts | 27 ++++++++++++++++----------- ts/plugins.ts | 9 +++++++-- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/ts/index.ts b/ts/index.ts index 71ca852..a6d2661 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -7,29 +7,34 @@ const __dirname = dirname(fileURLToPath(import.meta.url)); export const runPath = async (pathArg: string) => { await runCli(pathArg); -} +}; export const runCli = async (pathArg?: string) => { // contents of argv array // process.argv[0] -> node Executable // process.argv[1] -> tsrun executable const relativePathToTsFile = pathArg ? pathArg : process.argv[2]; - const absolutePathToTsFile = plugins.path.join(process.cwd(), relativePathToTsFile); - - + const absolutePathToTsFile = plugins.path.isAbsolute(relativePathToTsFile) + ? relativePathToTsFile + : plugins.path.join(process.cwd(), relativePathToTsFile); + 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' + executor: 'bash', }); - const tsNodeLoaderPath = plugins.path.join(__dirname, 'loader.js') + 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; - }) : ''}`); - + smartshellInstance.exec( + `node --loader ${tsNodeLoaderPath} ${absolutePathToTsFile} ${ + process.argv.length > 0 + ? process.argv.reduce((prevArg, currentArg) => { + return prevArg + ' ' + currentArg; + }) + : '' + }` + ); }; diff --git a/ts/plugins.ts b/ts/plugins.ts index 7d3243b..42072b1 100644 --- a/ts/plugins.ts +++ b/ts/plugins.ts @@ -1,3 +1,10 @@ +// node native +import * as path from 'path'; + +export { + path +} + // @pushrocks scope import * as smartshell from '@pushrocks/smartshell'; @@ -6,10 +13,8 @@ export { } // third party scope -import * as path from 'path'; import * as tsNode from 'ts-node'; export { - path, tsNode } \ No newline at end of file