fix(core): fix argument parsing

This commit is contained in:
Philipp Kunz 2018-06-25 10:23:15 +02:00
parent c129560e07
commit 3971df8ad8
4 changed files with 16 additions and 6 deletions

8
dist/index.js vendored
View File

@ -8,7 +8,11 @@ tsNode.register({
} }
}); });
if (process.env.CLI_CALL) { if (process.env.CLI_CALL) {
const pathToLoad = path.join(process.cwd(), process.argv.pop()); // contents of argv array
// process.argv[0] -> node Executable
// process.argv[1] -> tsrun executable
const pathToTsFile = process.argv[2];
const pathToLoad = path.join(process.cwd(), pathToTsFile);
Promise.resolve().then(() => require(pathToLoad)); Promise.resolve().then(() => require(pathToLoad));
} }
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLGtDQUFrQztBQUNsQyw2QkFBNkI7QUFFN0IsTUFBTSxDQUFDLFFBQVEsQ0FBQztJQUNkLGVBQWUsRUFBRTtRQUNmLEdBQUcsRUFBRSxDQUFFLFFBQVEsRUFBRSxRQUFRLENBQUU7S0FDNUI7Q0FDRixDQUFDLENBQUM7QUFFSCxJQUFJLE9BQU8sQ0FBQyxHQUFHLENBQUMsUUFBUSxFQUFFO0lBQ3hCLE1BQU0sVUFBVSxHQUFHLElBQUksQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFDLEdBQUcsRUFBRSxFQUFFLE9BQU8sQ0FBQyxJQUFJLENBQUMsR0FBRyxFQUFFLENBQUMsQ0FBQztJQUNoRSxxQ0FBTyxVQUFVLEdBQUU7Q0FDcEIifQ== //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLGtDQUFrQztBQUNsQyw2QkFBNkI7QUFFN0IsTUFBTSxDQUFDLFFBQVEsQ0FBQztJQUNkLGVBQWUsRUFBRTtRQUNmLEdBQUcsRUFBRSxDQUFFLFFBQVEsRUFBRSxRQUFRLENBQUU7S0FDNUI7Q0FDRixDQUFDLENBQUM7QUFFSCxJQUFJLE9BQU8sQ0FBQyxHQUFHLENBQUMsUUFBUSxFQUFFO0lBQ3hCLHlCQUF5QjtJQUN6QixxQ0FBcUM7SUFDckMsc0NBQXNDO0lBQ3RDLE1BQU0sWUFBWSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDLENBQUE7SUFFcEMsTUFBTSxVQUFVLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUMsR0FBRyxFQUFFLEVBQUUsWUFBWSxDQUFDLENBQUM7SUFDMUQscUNBQU8sVUFBVSxHQUFFO0NBQ3BCIn0=

5
package-lock.json generated
View File

@ -1,5 +1,5 @@
{ {
"name": "tsrun", "name": "@gitzone/tsrun",
"version": "1.0.5", "version": "1.0.5",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
@ -7,7 +7,8 @@
"@types/node": { "@types/node": {
"version": "10.3.0", "version": "10.3.0",
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.3.0.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-10.3.0.tgz",
"integrity": "sha512-hWzNviaVFIr1TqcRA8ou49JaSHp+Rfabmnqg2kNvusKqLhPU0rIsGPUj5WJJ7ld4Bb7qdgLmIhLfCD1qS08IVA==" "integrity": "sha512-hWzNviaVFIr1TqcRA8ou49JaSHp+Rfabmnqg2kNvusKqLhPU0rIsGPUj5WJJ7ld4Bb7qdgLmIhLfCD1qS08IVA==",
"dev": true
}, },
"arrify": { "arrify": {
"version": "1.0.1", "version": "1.0.1",

View File

@ -10,7 +10,7 @@
"tsrun": "dist/cli.js" "tsrun": "dist/cli.js"
}, },
"scripts": { "scripts": {
"test": "(npmts --notest && node dist/cli.js -d test/test.ts)", "test": "(npmts --notest && node dist/cli.js test/test.ts)",
"format": "(gitzone format)", "format": "(gitzone format)",
"build": "echo \"Not needed for now\"" "build": "echo \"Not needed for now\""
}, },

View File

@ -8,6 +8,11 @@ tsNode.register({
}); });
if (process.env.CLI_CALL) { if (process.env.CLI_CALL) {
const pathToLoad = path.join(process.cwd(), process.argv.pop()); // contents of argv array
// process.argv[0] -> node Executable
// process.argv[1] -> tsrun executable
const pathToTsFile = process.argv[2]
const pathToLoad = path.join(process.cwd(), pathToTsFile);
import(pathToLoad); import(pathToLoad);
} }