Socket
Socket
Sign inDemoInstall

ts-node

Package Overview
Dependencies
7
Maintainers
1
Versions
128
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 6.0.5 to 6.1.0

1

dist/bin.d.ts

@@ -0,1 +1,2 @@

#!/usr/bin/env node
export {};

19

dist/bin.js

@@ -10,3 +10,2 @@ #!/usr/bin/env node

var minimist = require("minimist");
var chalk_1 = require("chalk");
var diff_1 = require("diff");

@@ -19,3 +18,3 @@ var vm_1 = require("vm");

string: ['eval', 'print', 'compiler', 'project', 'ignoreDiagnostics', 'require', 'cacheDirectory', 'ignore'],
boolean: ['help', 'transpileOnly', 'typeCheck', 'version', 'cache', 'skipProject', 'skipIgnore'],
boolean: ['help', 'transpileOnly', 'typeCheck', 'version', 'cache', 'pretty', 'skipProject', 'skipIgnore'],
alias: {

@@ -47,3 +46,3 @@ eval: ['e'],

if (argv.help) {
console.log("\nUsage: ts-node [options] [ -e script | script.ts ] [arguments]\n\nOptions:\n\n -e, --eval [code] Evaluate code\n -p, --print [code] Evaluate code and print result\n -r, --require [path] Require a node module before execution\n\n -h, --help Print CLI usage\n -v, --version Print module version information\n\n -T, --transpile-only Use TypeScript's faster `transpileModule`\n --cache-directory Configure the output file cache directory\n -I, --ignore [pattern] Override the path patterns to skip compilation\n -P, --project [path] Path to TypeScript JSON project file\n -C, --compiler [name] Specify a custom TypeScript compiler\n -D, --ignoreDiagnostics [code] Ignore TypeScript warnings by diagnostic code\n -O, --compilerOptions [opts] JSON object to merge with compiler options\n\n --no-cache Disable the local TypeScript Node cache\n --skip-project Skip reading `tsconfig.json`\n --skip-ignore Skip `--ignore` checks\n");
console.log("\nUsage: ts-node [options] [ -e script | script.ts ] [arguments]\n\nOptions:\n\n -e, --eval [code] Evaluate code\n -p, --print [code] Evaluate code and print result\n -r, --require [path] Require a node module before execution\n\n -h, --help Print CLI usage\n -v, --version Print module version information\n\n -T, --transpile-only Use TypeScript's faster `transpileModule`\n --cache-directory Configure the output file cache directory\n -I, --ignore [pattern] Override the path patterns to skip compilation\n -P, --project [path] Path to TypeScript JSON project file\n -C, --compiler [name] Specify a custom TypeScript compiler\n -D, --ignoreDiagnostics [code] Ignore TypeScript warnings by diagnostic code\n -O, --compilerOptions [opts] JSON object to merge with compiler options\n\n --pretty Use pretty diagnostic formatter\n --no-cache Disable the local TypeScript Node cache\n --skip-project Skip reading `tsconfig.json`\n --skip-ignore Skip `--ignore` checks\n");
process.exit(0);

@@ -57,2 +56,3 @@ }

var service = index_1.register({
pretty: argv.pretty,
typeCheck: argv.typeCheck,

@@ -128,3 +128,3 @@ transpileOnly: argv.transpileOnly,

if (error instanceof index_1.TSError) {
console.error(index_1.printError(error));
console.error(error.diagnosticText);
process.exit(1);

@@ -203,3 +203,3 @@ }

undo();
repl.outputStream.write(chalk_1.default.bold(name) + "\n" + (comment ? comment + "\n" : ''));
repl.outputStream.write(name + "\n" + (comment ? comment + "\n" : ''));
repl.displayPrompt();

@@ -230,3 +230,4 @@ }

else {
err = index_1.printError(error);
console.error(error.diagnosticText);
err = undefined;
}

@@ -300,3 +301,3 @@ }

}
var RECOVERY_CODES = [
var RECOVERY_CODES = new Set([
1003,

@@ -308,3 +309,3 @@ 1005,

1161 // "Unterminated regular expression literal."
];
]);
/**

@@ -314,4 +315,4 @@ * Check if a function can recover gracefully.

function isRecoverable(error) {
return error.diagnostics.every(function (x) { return RECOVERY_CODES.indexOf(x.code) > -1; });
return error.diagnosticCodes.every(function (code) { return RECOVERY_CODES.has(code); });
}
//# sourceMappingURL=bin.js.map
import { BaseError } from 'make-error';
import * as TS from 'typescript';
import * as _ts from 'typescript';
/**
* @internal
*/
export declare const INSPECT_CUSTOM: symbol;
/**
* Common TypeScript interfaces between versions.
*/
export interface TSCommon {
version: typeof TS.version;
sys: typeof TS.sys;
ScriptSnapshot: typeof TS.ScriptSnapshot;
displayPartsToString: typeof TS.displayPartsToString;
createLanguageService: typeof TS.createLanguageService;
getDefaultLibFilePath: typeof TS.getDefaultLibFilePath;
getPreEmitDiagnostics: typeof TS.getPreEmitDiagnostics;
flattenDiagnosticMessageText: typeof TS.flattenDiagnosticMessageText;
transpileModule: typeof TS.transpileModule;
ModuleKind: typeof TS.ModuleKind;
ScriptTarget: typeof TS.ScriptTarget;
findConfigFile: typeof TS.findConfigFile;
readConfigFile: typeof TS.readConfigFile;
parseJsonConfigFileContent: typeof TS.parseJsonConfigFileContent;
version: typeof _ts.version;
sys: typeof _ts.sys;
ScriptSnapshot: typeof _ts.ScriptSnapshot;
displayPartsToString: typeof _ts.displayPartsToString;
createLanguageService: typeof _ts.createLanguageService;
getDefaultLibFilePath: typeof _ts.getDefaultLibFilePath;
getPreEmitDiagnostics: typeof _ts.getPreEmitDiagnostics;
flattenDiagnosticMessageText: typeof _ts.flattenDiagnosticMessageText;
transpileModule: typeof _ts.transpileModule;
ModuleKind: typeof _ts.ModuleKind;
ScriptTarget: typeof _ts.ScriptTarget;
findConfigFile: typeof _ts.findConfigFile;
readConfigFile: typeof _ts.readConfigFile;
parseJsonConfigFileContent: typeof _ts.parseJsonConfigFileContent;
formatDiagnostics: typeof _ts.formatDiagnostics;
formatDiagnosticsWithColorAndContext: typeof _ts.formatDiagnosticsWithColorAndContext;
}

@@ -30,2 +36,3 @@ /**

export interface Options {
pretty?: boolean | null;
typeCheck?: boolean | null;

@@ -44,3 +51,3 @@ transpileOnly?: boolean | null;

fileExists?: (path: string) => boolean;
transformers?: TS.CustomTransformers;
transformers?: _ts.CustomTransformers;
}

@@ -74,5 +81,6 @@ /**

export declare class TSError extends BaseError {
diagnostics: TSDiagnostic[];
diagnosticText: string;
diagnosticCodes: number[];
name: string;
constructor(diagnostics: TSDiagnostic[]);
constructor(diagnosticText: string, diagnosticCodes: number[]);
}

@@ -94,20 +102,1 @@ /**

export declare function register(opts?: Options): Register;
/**
* Format an array of diagnostics.
*/
export declare function formatDiagnostics(diagnostics: TS.Diagnostic[], cwd: string, ts: TSCommon, lineOffset: number): TSDiagnostic[];
/**
* Internal diagnostic representation.
*/
export interface TSDiagnostic {
message: string;
code: number;
}
/**
* Format a diagnostic object into a string.
*/
export declare function formatDiagnostic(diagnostic: TS.Diagnostic, cwd: string, ts: TSCommon, lineOffset: number): TSDiagnostic;
/**
* Stringify the `TSError` instance.
*/
export declare function printError(error: TSError): string;

@@ -17,3 +17,2 @@ "use strict";

var sourceMapSupport = require("source-map-support");
var chalk_1 = require("chalk");
var mkdirp = require("mkdirp");

@@ -24,3 +23,10 @@ var crypto = require("crypto");

var make_error_1 = require("make-error");
var pkg = require('../package.json');
var util = require("util");
/**
* @internal
*/
exports.INSPECT_CUSTOM = util.inspect.custom || 'inspect';
/**
* Debugging `ts-node`.
*/
var shouldDebug = yn(process.env.TS_NODE_DEBUG);

@@ -39,3 +45,3 @@ var debug = shouldDebug ? console.log.bind(console, 'ts-node') : function () { return undefined; };

*/
exports.VERSION = pkg.version;
exports.VERSION = require('../package.json').version;
/**

@@ -46,2 +52,3 @@ * Default register options.

cache: yn(process.env['TS_NODE_CACHE'], { default: true }),
pretty: yn(process.env['TS_NODE_PRETTY']),
cacheDirectory: process.env['TS_NODE_CACHE_DIRECTORY'],

@@ -95,8 +102,15 @@ compiler: process.env['TS_NODE_COMPILER'],

__extends(TSError, _super);
function TSError(diagnostics) {
var _this = _super.call(this, "\u2A2F Unable to compile TypeScript\n" + diagnostics.map(function (x) { return x.message; }).join('\n')) || this;
_this.diagnostics = diagnostics;
function TSError(diagnosticText, diagnosticCodes) {
var _this = _super.call(this, "\u2A2F Unable to compile TypeScript:\n" + diagnosticText) || this;
_this.diagnosticText = diagnosticText;
_this.diagnosticCodes = diagnosticCodes;
_this.name = 'TSError';
return _this;
}
/**
* @internal
*/
TSError.prototype[exports.INSPECT_CUSTOM] = function () {
return this.diagnosticText;
};
return TSError;

@@ -140,2 +154,3 @@ }(make_error_1.BaseError));

var cwd = process.cwd();
var compilerOptions = options.compilerOptions, project = options.project, skipProject = options.skipProject;
var compiler = options.compiler || 'typescript';

@@ -147,10 +162,22 @@ var typeCheck = options.typeCheck === true || options.transpileOnly !== true;

var fileExists = options.fileExists || ts.sys.fileExists;
var config = readConfig(cwd, ts, options.compilerOptions, fileExists, readFile, options.project, options.skipProject);
var configDiagnostics = filterDiagnostics(config.errors, ignoreDiagnostics);
var config = readConfig(cwd, ts, fileExists, readFile, compilerOptions, project, skipProject);
var configDiagnosticList = filterDiagnostics(config.errors, ignoreDiagnostics);
var extensions = ['.ts', '.tsx'];
var cachedir = path_1.join(path_1.resolve(cwd, cacheDirectory), getCompilerDigest({ version: ts.version, typeCheck: typeCheck, ignoreDiagnostics: ignoreDiagnostics, config: config, compiler: compiler }));
var diagnosticHost = {
getNewLine: function () { return os_1.EOL; },
getCurrentDirectory: function () { return cwd; },
getCanonicalFileName: function (path) { return path; }
};
var formatDiagnostics = options.pretty
? ts.formatDiagnosticsWithColorAndContext
: ts.formatDiagnostics;
function createTSError(diagnostics) {
var diagnosticText = formatDiagnostics(diagnostics, diagnosticHost);
var diagnosticCodes = diagnostics.map(function (x) { return x.code; });
return new TSError(diagnosticText, diagnosticCodes);
}
// Render the configuration errors and exit the script.
if (configDiagnostics.length) {
throw new TSError(formatDiagnostics(configDiagnostics, cwd, ts, 0));
}
if (configDiagnosticList.length)
throw createTSError(configDiagnosticList);
// Enable `allowJs` when flag is set.

@@ -186,5 +213,4 @@ if (config.options.allowJs) {

[];
if (diagnosticList.length) {
throw new TSError(formatDiagnostics(diagnosticList, cwd, ts, lineOffset));
}
if (diagnosticList.length)
throw createTSError(diagnosticList);
return [result.outputText, result.sourceMapText];

@@ -248,5 +274,4 @@ };

var diagnosticList = filterDiagnostics(diagnostics, ignoreDiagnostics);
if (diagnosticList.length) {
throw new TSError(formatDiagnostics(diagnosticList, cwd, ts, lineOffset));
}
if (diagnosticList.length)
throw createTSError(diagnosticList);
if (output.emitSkipped) {

@@ -314,2 +339,3 @@ throw new TypeError(path_1.relative(cwd, fileName) + ": Emit skipped");

delete config.options.declarationDir;
delete config.options.declarationMap;
// Target ES5 output by default (instead of ES3).

@@ -328,3 +354,3 @@ if (config.options.target === undefined) {

*/
function readConfig(cwd, ts, compilerOptions, fileExists, readFile, project, noProject) {
function readConfig(cwd, ts, fileExists, readFile, compilerOptions, project, noProject) {
var config = { compilerOptions: {} };

@@ -340,5 +366,5 @@ var basePath = normalizeSlashes(cwd);

var result = ts.readConfigFile(configFileName, readFile);
if (result.error) {
throw new TSError([formatDiagnostic(result.error, cwd, ts, 0)]);
}
// Return diagnostics.
if (result.error)
return { errors: [result.error] };
config = result.config;

@@ -435,35 +461,2 @@ basePath = normalizeSlashes(path_1.dirname(configFileName));

}
/**
* Format an array of diagnostics.
*/
function formatDiagnostics(diagnostics, cwd, ts, lineOffset) {
return diagnostics.map(function (x) { return formatDiagnostic(x, cwd, ts, lineOffset); });
}
exports.formatDiagnostics = formatDiagnostics;
/**
* Format a diagnostic object into a string.
*/
function formatDiagnostic(diagnostic, cwd, ts, lineOffset) {
var messageText = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
var code = diagnostic.code;
if (diagnostic.file) {
var path = path_1.relative(cwd, diagnostic.file.fileName);
if (diagnostic.start) {
var _a = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start), line = _a.line, character = _a.character;
var message = path + " (" + (line + 1 + lineOffset) + "," + (character + 1) + "): " + messageText + " (" + code + ")";
return { message: message, code: code };
}
return { message: path + ": " + messageText + " (" + code + ")", code: code };
}
return { message: messageText + " (" + code + ")", code: code };
}
exports.formatDiagnostic = formatDiagnostic;
/**
* Stringify the `TSError` instance.
*/
function printError(error) {
var title = chalk_1.default.red('тип') + " Unable to compile TypeScript";
return chalk_1.default.bold(title) + "\n" + error.diagnostics.map(function (x) { return x.message; }).join('\n');
}
exports.printError = printError;
//# sourceMappingURL=index.js.map

@@ -94,6 +94,4 @@ "use strict";

}
chai_1.expect(err.message).to.match(new RegExp(
// Node 0.10 can not override the `lineOffset` option.
'\\[eval\\]\\.ts \\(1,59\\): Argument of type \'(?:number|123)\' ' +
'is not assignable to parameter of type \'string\'\\. \\(2345\\)'));
chai_1.expect(err.message).to.match(new RegExp('TS2345: Argument of type \'(?:number|123)\' ' +
'is not assignable to parameter of type \'string\'\\.'));
return done();

@@ -100,0 +98,0 @@ });

{
"name": "ts-node",
"version": "6.0.5",
"version": "6.1.0",
"description": "TypeScript execution environment and REPL for node",

@@ -73,7 +73,6 @@ "main": "dist/index.js",

"tslint-config-standard": "^7.0.0",
"typescript": "^2.8.1"
"typescript": "^2.8.3"
},
"dependencies": {
"arrify": "^1.0.0",
"chalk": "^2.3.0",
"diff": "^3.1.0",

@@ -83,5 +82,5 @@ "make-error": "^1.1.1",

"mkdirp": "^0.5.1",
"source-map-support": "^0.5.3",
"source-map-support": "^0.5.6",
"yn": "^2.0.0"
}
}

@@ -123,3 +123,3 @@ # TypeScript Node

* `--transpileOnly` Use TypeScript's faster `transpileModule` (`TS_NODE_TRANSPILE_ONLY`)
* `-T, --transpileOnly` Use TypeScript's faster `transpileModule` (`TS_NODE_TRANSPILE_ONLY`)
* `--cacheDirectory` Configure the output file cache directory (`TS_NODE_CACHE_DIRECTORY`)

@@ -131,2 +131,3 @@ * `-I, --ignore [pattern]` Override the path patterns to skip compilation (`TS_NODE_IGNORE`)

* `-O, --compilerOptions [opts]` JSON object to merge with compiler options (`TS_NODE_COMPILER_OPTIONS`)
* `--pretty` Use pretty diagnostic formatter (`TS_NODE_PRETTY`)
* `--no-cache` Disable the local TypeScript Node cache (`TS_NODE_CACHE`)

@@ -133,0 +134,0 @@ * `--skip-project` Skip project config resolution and loading (`TS_NODE_SKIP_PROJECT`)

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with тЪбя╕П by Socket Inc