+2
-2
| const { remove } = require('fs-extra') | ||
| const { outfile } = require('./utils') | ||
| const { runnerFilePath } = require('./utils') | ||
| remove(outfile) | ||
| remove(runnerFilePath) |
+4
-4
@@ -7,11 +7,11 @@ #!/usr/bin/env node | ||
| const { existsSync } = require('fs') | ||
| const { outfile } = require('./utils') | ||
| const { runnerFilePath } = require('./utils') | ||
| const execute = () => spawnSync( | ||
| process.execPath, | ||
| [`${outfile}`].concat(process.argv.slice(2)), | ||
| [`${runnerFilePath}`].concat(process.argv.slice(2)), | ||
| { stdio: 'inherit', detached: true } | ||
| ) | ||
| if (existsSync(outfile)) { | ||
| if (existsSync(runnerFilePath)) { | ||
| execute() | ||
@@ -21,3 +21,3 @@ } else { | ||
| entryPoints: [join(__dirname, '..', 'src', 'index.ts')], | ||
| outfile, | ||
| outfile: runnerFilePath, | ||
| bundle: true, | ||
@@ -24,0 +24,0 @@ platform: 'node', |
+1
-1
| const { join } = require('path') | ||
| module.exports = { | ||
| outfile: join(__dirname, '..', '.cache', 'runner.js') | ||
| runnerFilePath: join(__dirname, '..', '.cache', 'runner.js') | ||
| } |
+1
-1
| { | ||
| "name": "xtsr", | ||
| "version": "0.2.1", | ||
| "version": "0.2.2", | ||
| "description": "A CLI program that runs your Typescript file directly in Nodejs. IMMEDIATLY ⚡️", | ||
@@ -5,0 +5,0 @@ "bin": { |
+14
-6
| import { Command } from 'commander' | ||
| import { join, resolve } from 'path' | ||
| import { join, parse, resolve } from 'path' | ||
| import esbuild from 'esbuild' | ||
@@ -11,7 +11,10 @@ import nodeExternalsPlugin from 'esbuild-node-externals' | ||
| program.on('command:*', () => { | ||
| const [tsFile, ...restOptions] = program.args | ||
| const absoluteTsFilePath = resolve(tsFile) | ||
| if (!existsSync(absoluteTsFilePath)) { | ||
| console.error(`Error: Could not resolve ${absoluteTsFilePath}`) | ||
| const fullPath = resolve(tsFile) | ||
| const { dir: dirname } = parse(fullPath) | ||
| if (!existsSync(fullPath)) { | ||
| console.error(`Error: Could not resolve ${fullPath}`) | ||
| process.exit(1) | ||
@@ -21,4 +24,9 @@ } | ||
| const outfile = join(cacheDir, 'out', 'program.js') | ||
| const injectJs = ` | ||
| process.argv[1] = '${fullPath}' | ||
| var __dirname = '${dirname}' | ||
| var __filename = '${fullPath}' | ||
| ` | ||
| esbuild.build({ | ||
| entryPoints: [absoluteTsFilePath], | ||
| entryPoints: [fullPath], | ||
| outfile, | ||
@@ -30,3 +38,3 @@ bundle: true, | ||
| banner: { | ||
| js: `process.argv[1] = '${absoluteTsFilePath}'` | ||
| js: injectJs | ||
| }, | ||
@@ -33,0 +41,0 @@ plugins: [nodeExternalsPlugin()] |
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 2 instances in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 2 instances in 1 package
4453
3.53%72
9.09%