Compare commits

..

12 Commits

Author SHA1 Message Date
d011f10b9b 1.2.28 2022-03-12 21:59:15 +01:00
d1baa20aad fix(core): update 2022-03-12 21:59:14 +01:00
71779693d7 1.2.27 2022-03-12 21:52:14 +01:00
1113251aea fix(core): update 2022-03-12 21:52:14 +01:00
e41cd896bb 1.2.26 2022-03-12 19:13:56 +01:00
ba44007fb2 fix(core): update 2022-03-12 19:13:56 +01:00
8d1362f14b 1.2.25 2022-03-12 18:54:20 +01:00
61ceb03962 fix(core): update 2022-03-12 18:54:19 +01:00
ab3ec90245 1.2.24 2022-03-12 18:50:18 +01:00
b51cda08c4 fix(core): update 2022-03-12 18:50:17 +01:00
b8332e1de4 1.2.23 2022-03-12 14:52:42 +01:00
da9a73bc79 fix(core): update 2022-03-12 14:52:42 +01:00
4 changed files with 41 additions and 22 deletions

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "@gitzone/tsrun",
"version": "1.2.22",
"version": "1.2.28",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@gitzone/tsrun",
"version": "1.2.22",
"version": "1.2.28",
"license": "MIT",
"dependencies": {
"@pushrocks/smartfile": "^9.0.6",

View File

@ -1,6 +1,6 @@
{
"name": "@gitzone/tsrun",
"version": "1.2.22",
"version": "1.2.28",
"description": "run typescript programs efficiently",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",

View File

@ -1,27 +1,39 @@
import * as plugins from './plugins.js';
const __dirname = plugins.path.dirname(plugins.url.fileURLToPath(import.meta.url));
import { dirname } from 'path';
import { fileURLToPath } from 'url';
export const runPath = async (pathArg: string, fromFileUrl?: string) => {
pathArg = fromFileUrl
? plugins.path.join(plugins.path.dirname(plugins.url.fileURLToPath(fromFileUrl)), pathArg)
: pathArg;
await runCli(pathArg);
};
const __dirname = dirname(fileURLToPath(import.meta.url));
export const runCli = async () => {
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.isAbsolute(relativePathToTsFile)
? relativePathToTsFile
: 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'
executor: 'bash',
});
smartshellInstance.exec(`node --loader ${tsNodeLoaderPath} ${pathToLoad} ${process.argv.reduce((prevArg, currentArg) => {
return 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;
})
: ''
}`
);
};

View File

@ -1,3 +1,12 @@
// node native
import * as path from 'path';
import * as url from 'url';
export {
path,
url
}
// @pushrocks scope
import * as smartshell from '@pushrocks/smartshell';
@ -6,10 +15,8 @@ export {
}
// third party scope
import * as path from 'path';
import * as tsNode from 'ts-node';
export {
path,
tsNode
}