Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
d011f10b9b | |||
d1baa20aad | |||
71779693d7 | |||
1113251aea | |||
e41cd896bb | |||
ba44007fb2 |
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@gitzone/tsrun",
|
"name": "@gitzone/tsrun",
|
||||||
"version": "1.2.25",
|
"version": "1.2.28",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@gitzone/tsrun",
|
"name": "@gitzone/tsrun",
|
||||||
"version": "1.2.25",
|
"version": "1.2.28",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/smartfile": "^9.0.6",
|
"@pushrocks/smartfile": "^9.0.6",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@gitzone/tsrun",
|
"name": "@gitzone/tsrun",
|
||||||
"version": "1.2.25",
|
"version": "1.2.28",
|
||||||
"description": "run typescript programs efficiently",
|
"description": "run typescript programs efficiently",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist_ts/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
|
35
ts/index.ts
35
ts/index.ts
@ -1,28 +1,39 @@
|
|||||||
import * as plugins from './plugins.js';
|
import * as plugins from './plugins.js';
|
||||||
|
const __dirname = plugins.path.dirname(plugins.url.fileURLToPath(import.meta.url));
|
||||||
|
|
||||||
import { dirname } from 'path';
|
export const runPath = async (pathArg: string, fromFileUrl?: string) => {
|
||||||
import { fileURLToPath } from 'url';
|
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 (pathArg?: string) => {
|
||||||
|
|
||||||
export const runCli = async () => {
|
|
||||||
// contents of argv array
|
// contents of argv array
|
||||||
// process.argv[0] -> node Executable
|
// process.argv[0] -> node Executable
|
||||||
// process.argv[1] -> tsrun 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); // this ensures transparent arguments for the child process
|
process.argv.splice(0, 3); // this ensures transparent arguments for the child process
|
||||||
|
|
||||||
|
// lets setup things for execution
|
||||||
const smartshellInstance = new plugins.smartshell.Smartshell({
|
const smartshellInstance = new plugins.smartshell.Smartshell({
|
||||||
executor: 'bash'
|
executor: 'bash',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const tsNodeLoaderPath = plugins.path.join(__dirname, 'loader.js');
|
||||||
// note: -> reduce on emtpy array does not work
|
// note: -> reduce on emtpy array does not work
|
||||||
// thus check needed before reducing the argv array
|
// thus check needed before reducing the argv array
|
||||||
smartshellInstance.exec(`node --loader ${tsNodeLoaderPath} ${pathToLoad} ${process.argv.length > 0 ? process.argv.reduce((prevArg, currentArg) => {
|
smartshellInstance.exec(
|
||||||
|
`node --loader ${tsNodeLoaderPath} ${absolutePathToTsFile} ${
|
||||||
|
process.argv.length > 0
|
||||||
|
? process.argv.reduce((prevArg, currentArg) => {
|
||||||
return prevArg + ' ' + currentArg;
|
return prevArg + ' ' + currentArg;
|
||||||
}) : ''}`);
|
})
|
||||||
|
: ''
|
||||||
|
}`
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
@ -1,3 +1,12 @@
|
|||||||
|
// node native
|
||||||
|
import * as path from 'path';
|
||||||
|
import * as url from 'url';
|
||||||
|
|
||||||
|
export {
|
||||||
|
path,
|
||||||
|
url
|
||||||
|
}
|
||||||
|
|
||||||
// @pushrocks scope
|
// @pushrocks scope
|
||||||
import * as smartshell from '@pushrocks/smartshell';
|
import * as smartshell from '@pushrocks/smartshell';
|
||||||
|
|
||||||
@ -6,10 +15,8 @@ export {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// third party scope
|
// third party scope
|
||||||
import * as path from 'path';
|
|
||||||
import * as tsNode from 'ts-node';
|
import * as tsNode from 'ts-node';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
path,
|
|
||||||
tsNode
|
tsNode
|
||||||
}
|
}
|
Reference in New Issue
Block a user