Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
e41cd896bb | |||
ba44007fb2 | |||
8d1362f14b | |||
61ceb03962 | |||
ab3ec90245 | |||
b51cda08c4 | |||
b8332e1de4 | |||
da9a73bc79 |
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@gitzone/tsrun",
|
||||
"version": "1.2.22",
|
||||
"version": "1.2.26",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@gitzone/tsrun",
|
||||
"version": "1.2.22",
|
||||
"version": "1.2.26",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@pushrocks/smartfile": "^9.0.6",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@gitzone/tsrun",
|
||||
"version": "1.2.22",
|
||||
"version": "1.2.26",
|
||||
"description": "run typescript programs efficiently",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
|
24
ts/index.ts
24
ts/index.ts
@ -5,23 +5,31 @@ import { fileURLToPath } from 'url';
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
export const runCli = async () => {
|
||||
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 pathToTsFile = process.argv[2];
|
||||
const relativePathToTsFile = pathArg ? pathArg : process.argv[2];
|
||||
const absolutePathToTsFile = plugins.path.join(process.cwd(), relativePathToTsFile);
|
||||
|
||||
const tsNodeLoaderPath = plugins.path.join(__dirname, 'loader.js')
|
||||
const pathToLoad = plugins.path.join(process.cwd(), pathToTsFile);
|
||||
process.argv.splice(0, 3);
|
||||
// console.log(process.argv);
|
||||
|
||||
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'
|
||||
});
|
||||
|
||||
smartshellInstance.exec(`node --loader ${tsNodeLoaderPath} ${pathToLoad} ${process.argv.reduce((prevArg, currentArg) => {
|
||||
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;
|
||||
})}`);
|
||||
}) : ''}`);
|
||||
|
||||
};
|
||||
|
Reference in New Issue
Block a user