This commit is contained in:
Domen Kožar 2019-11-19 17:50:30 +01:00
parent cd5893b2c6
commit 70742d22d9
No known key found for this signature in database
GPG key ID: C2FFBCAFD2C24246
6774 changed files with 1602535 additions and 1 deletions

21
node_modules/ts-node/LICENSE generated vendored Normal file
View file

@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014 Blake Embrey (hello@blakeembrey.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

222
node_modules/ts-node/README.md generated vendored Normal file
View file

@ -0,0 +1,222 @@
# ![TypeScript Node](logo.svg)
[![NPM version][npm-image]][npm-url]
[![NPM downloads][downloads-image]][downloads-url]
[![Build status][travis-image]][travis-url]
[![Test coverage][coveralls-image]][coveralls-url]
> TypeScript execution and REPL for node.js, with source map support. **Works with `typescript@>=2.0`**.
## Installation
```sh
# Locally in your project.
npm install -D ts-node
npm install -D typescript
# Or globally with TypeScript.
npm install -g ts-node
npm install -g typescript
```
**Tip:** Installing modules locally allows you to control and share the versions through `package.json`. TS Node will always resolve the compiler from `cwd` before checking relative to its own installation.
## Usage
```sh
# Execute a script as `node` + `tsc`.
ts-node script.ts
# Starts a TypeScript REPL.
ts-node
# Execute code with TypeScript.
ts-node -e 'console.log("Hello, world!")'
# Execute, and print, code with TypeScript.
ts-node -p -e '"Hello, world!"'
# Pipe scripts to execute with TypeScript.
echo "console.log('Hello, world!')" | ts-node
```
![TypeScript REPL](https://github.com/TypeStrong/ts-node/raw/master/screenshot.png)
### Programmatic
You can require `ts-node` and register the loader for future requires by using `require('ts-node').register({ /* options */ })`. You can also use file shortcuts - `node -r ts-node/register` or `node -r ts-node/register/transpile-only` - depending on your preferences.
**Note:** If you need to use advanced node.js CLI arguments (e.g. `--inspect`), use them with `node -r ts-node/register` instead of the `ts-node` CLI.
### Mocha
```sh
mocha --require ts-node/register --watch-extensions ts,tsx "test/**/*.{ts,tsx}" [...args]
```
**Note:** `--watch-extensions` is only used in `--watch` mode.
### Tape
```sh
ts-node node_modules/tape/bin/tape [...args]
```
### Gulp
```sh
# Create a `gulpfile.ts` and run `gulp`.
gulp
```
### Visual Studio Code
Create a new node.js configuration, add `-r ts-node/register` to node args and move the `program` to the `args` list (so VS Code doesn't look for `outFiles`).
```json
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"runtimeArgs": [
"-r",
"ts-node/register"
],
"args": [
"${workspaceFolder}/index.ts"
]
}
```
**Note:** If you are using the `--project <tsconfig.json>` command line argument as per the [Configuration Options](#configuration-options), and want to apply this same behavior when launching in VS Code, add an "env" key into the launch configuration: `"env": { "TS_NODE_PROJECT": "<tsconfig.json>" }`.
## How It Works
**TypeScript Node** works by registering the TypeScript compiler for `.tsx?` and `.jsx?` (when `allowJs == true`) extensions. When node.js has an extension registered (via `require.extensions`), it will use the extension internally for module resolution. When an extension is unknown to node.js, it handles the file as `.js` (JavaScript). By default, **TypeScript Node** avoids compiling files in `/node_modules/` for three reasons:
1. Modules should always be published in a format node.js can consume
2. Transpiling the entire dependency tree will make your project slower
3. Differing behaviours between TypeScript and node.js (e.g. ES2015 modules) can result in a project that works until you decide to support a feature natively from node.js
**P.S.** This means if you don't register an extension, it is compiled as JavaScript. When `ts-node` is used with `allowJs`, JavaScript files are transpiled using the TypeScript compiler.
## Loading `tsconfig.json`
**Typescript Node** loads `tsconfig.json` automatically. Use `--skip-project` to skip loading the `tsconfig.json`.
**Tip**: You can use `ts-node` together with [tsconfig-paths](https://www.npmjs.com/package/tsconfig-paths) to load modules according to the `paths` section in `tsconfig.json`.
## Configuration Options
You can set options by passing them before the script path, via programmatic usage or via environment variables.
```sh
ts-node --compiler ntypescript --project src/tsconfig.json hello-world.ts
```
**Note:** [`ntypescript`](https://github.com/TypeStrong/ntypescript#readme) is an example of a TypeScript compatible `compiler`.
### CLI Options
Supports `--print`, `--eval` and `--require` from [node.js CLI options](https://nodejs.org/api/cli.html).
* `--help` Prints help text
* `--version` Prints version information
### CLI and Programmatic Options
_Environment variable denoted in parentheses._
* `-T, --transpile-only` Use TypeScript's faster `transpileModule` (`TS_NODE_TRANSPILE_ONLY`, default: `false`)
* `-I, --ignore [pattern]` Override the path patterns to skip compilation (`TS_NODE_IGNORE`, default: `/node_modules/`)
* `-P, --project [path]` Path to TypeScript JSON project file (`TS_NODE_PROJECT`)
* `-C, --compiler [name]` Specify a custom TypeScript compiler (`TS_NODE_COMPILER`, default: `typescript`)
* `-D, --ignore-diagnostics [code]` Ignore TypeScript warnings by diagnostic code (`TS_NODE_IGNORE_DIAGNOSTICS`)
* `-O, --compiler-options [opts]` JSON object to merge with compiler options (`TS_NODE_COMPILER_OPTIONS`)
* `--files` Load files from `tsconfig.json` on startup (`TS_NODE_FILES`, default: `false`)
* `--pretty` Use pretty diagnostic formatter (`TS_NODE_PRETTY`, default: `false`)
* `--skip-project` Skip project config resolution and loading (`TS_NODE_SKIP_PROJECT`, default: `false`)
* `--skip-ignore` Skip ignore checks (`TS_NODE_SKIP_IGNORE`, default: `false`)
* `--log-error` Logs errors of types instead of exit the process (`TS_NODE_LOG_ERROR`, default: `false`)
* `--prefer-ts-exts` Re-order file extensions so that TypeScript imports are preferred (`TS_NODE_PREFER_TS_EXTS`, default: `false`)
### Programmatic Only Options
* `transformers` `_ts.CustomTransformers | ((p: _ts.Program) => _ts.CustomTransformers)` An object with transformers or a function that accepts a program and returns an transformers object to pass to TypeScript. Function isn't available with `transpileOnly` flag
* `readFile` Custom TypeScript-compatible file reading function
* `fileExists` Custom TypeScript-compatible file existence function
## Help! My Types Are Missing!
**TypeScript Node** does _not_ use `files`, `include` or `exclude`, by default. This is because a large majority projects do not use all of the files in a project directory (e.g. `Gulpfile.ts`, runtime vs tests) and parsing every file for types slows startup time. Instead, `ts-node` starts with the script file (e.g. `ts-node index.ts`) and TypeScript resolves dependencies based on imports and references.
For global definitions, you can use the `typeRoots` compiler option. This requires that your type definitions be structured as type packages (not loose TypeScript definition files). More details on how this works can be found in the [TypeScript Handbook](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html#types-typeroots-and-types).
Example `tsconfig.json`:
```
{
"compilerOptions": {
"typeRoots" : ["./node_modules/@types", "./typings"]
}
}
```
Example project structure:
```
<project_root>/
-- tsconfig.json
-- typings/
-- <module_name>/
-- index.d.ts
```
Example module declaration file:
```
declare module '<module_name>' {
// module definitions go here
}
```
For module definitions, you can use [`paths`](https://www.typescriptlang.org/docs/handbook/module-resolution.html#path-mapping):
```json
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"custom-module-type": ["types/custom-module-type"]
}
}
}
```
An alternative approach for definitions of third-party libraries are [triple-slash directives](https://www.typescriptlang.org/docs/handbook/triple-slash-directives.html). This may be helpful if you prefer not to change your TypeScript `compilerOptions` or structure your custom type definitions when using `typeRoots`. Below is an example of the triple-slash directive as a relative path within your project:
```typescript
/// <reference types="./types/untyped_js_lib" />
import UntypedJsLib from "untyped_js_lib"
```
**Tip:** If you _must_ use `files`, enable `--files` flags or set `TS_NODE_FILES=true`.
## Watching and Restarting
**TypeScript Node** compiles source code via `require()`, watching files and code reloads are out of scope for the project. If you want to restart the `ts-node` process on file change, existing node.js tools such as [nodemon](https://github.com/remy/nodemon), [onchange](https://github.com/Qard/onchange) and [node-dev](https://github.com/fgnass/node-dev) work.
There's also [`ts-node-dev`](https://github.com/whitecolor/ts-node-dev), a modified version of [`node-dev`](https://github.com/fgnass/node-dev) using `ts-node` for compilation and won't restart the process on file change.
## License
MIT
[npm-image]: https://img.shields.io/npm/v/ts-node.svg?style=flat
[npm-url]: https://npmjs.org/package/ts-node
[downloads-image]: https://img.shields.io/npm/dm/ts-node.svg?style=flat
[downloads-url]: https://npmjs.org/package/ts-node
[travis-image]: https://img.shields.io/travis/TypeStrong/ts-node.svg?style=flat
[travis-url]: https://travis-ci.org/TypeStrong/ts-node
[coveralls-image]: https://img.shields.io/coveralls/TypeStrong/ts-node.svg?style=flat
[coveralls-url]: https://coveralls.io/r/TypeStrong/ts-node?branch=master

2
node_modules/ts-node/dist/bin.d.ts generated vendored Normal file
View file

@ -0,0 +1,2 @@
#!/usr/bin/env node
export {};

345
node_modules/ts-node/dist/bin.js generated vendored Executable file
View file

@ -0,0 +1,345 @@
#!/usr/bin/env node
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const path_1 = require("path");
const repl_1 = require("repl");
const util_1 = require("util");
const Module = require("module");
const arg = require("arg");
const diff_1 = require("diff");
const vm_1 = require("vm");
const fs_1 = require("fs");
const index_1 = require("./index");
const args = arg({
// Node.js-like options.
'--eval': String,
'--print': Boolean,
'--require': [String],
// CLI options.
'--files': Boolean,
'--help': Boolean,
'--version': arg.COUNT,
// Project options.
'--compiler': String,
'--compiler-options': index_1.parse,
'--project': String,
'--ignore-diagnostics': [String],
'--ignore': [String],
'--transpile-only': Boolean,
'--type-check': Boolean,
'--pretty': Boolean,
'--skip-project': Boolean,
'--skip-ignore': Boolean,
'--prefer-ts-exts': Boolean,
'--log-error': Boolean,
// Aliases.
'-e': '--eval',
'-p': '--print',
'-r': '--require',
'-h': '--help',
'-v': '--version',
'-T': '--transpile-only',
'-I': '--ignore',
'-P': '--project',
'-C': '--compiler',
'-D': '--ignore-diagnostics',
'-O': '--compiler-options'
}, {
stopAtPositional: true
});
const { '--help': help = false, '--version': version = 0, '--files': files = index_1.DEFAULTS.files, '--compiler': compiler = index_1.DEFAULTS.compiler, '--compiler-options': compilerOptions = index_1.DEFAULTS.compilerOptions, '--project': project = index_1.DEFAULTS.project, '--ignore-diagnostics': ignoreDiagnostics = index_1.DEFAULTS.ignoreDiagnostics, '--ignore': ignore = index_1.DEFAULTS.ignore, '--transpile-only': transpileOnly = index_1.DEFAULTS.transpileOnly, '--type-check': typeCheck = index_1.DEFAULTS.typeCheck, '--pretty': pretty = index_1.DEFAULTS.pretty, '--skip-project': skipProject = index_1.DEFAULTS.skipProject, '--skip-ignore': skipIgnore = index_1.DEFAULTS.skipIgnore, '--prefer-ts-exts': preferTsExts = index_1.DEFAULTS.preferTsExts, '--log-error': logError = index_1.DEFAULTS.logError } = args;
if (help) {
console.log(`
Usage: ts-node [options] [ -e script | script.ts ] [arguments]
Options:
-e, --eval [code] Evaluate code
-p, --print Print result of \`--eval\`
-r, --require [path] Require a node module before execution
-h, --help Print CLI usage
-v, --version Print module version information
-T, --transpile-only Use TypeScript's faster \`transpileModule\`
-I, --ignore [pattern] Override the path patterns to skip compilation
-P, --project [path] Path to TypeScript JSON project file
-C, --compiler [name] Specify a custom TypeScript compiler
-D, --ignore-diagnostics [code] Ignore TypeScript warnings by diagnostic code
-O, --compiler-options [opts] JSON object to merge with compiler options
--files Load files from \`tsconfig.json\` on startup
--pretty Use pretty diagnostic formatter
--skip-project Skip reading \`tsconfig.json\`
--skip-ignore Skip \`--ignore\` checks
--prefer-ts-exts Prefer importing TypeScript files over JavaScript files
`);
process.exit(0);
}
// Output project information.
if (version === 1) {
console.log(`v${index_1.VERSION}`);
process.exit(0);
}
const cwd = process.cwd();
const code = args['--eval'];
const isPrinted = args['--print'] !== undefined;
/**
* Eval helpers.
*/
const EVAL_FILENAME = `[eval].ts`;
const EVAL_PATH = path_1.join(cwd, EVAL_FILENAME);
const EVAL_INSTANCE = { input: '', output: '', version: 0, lines: 0 };
// Register the TypeScript compiler instance.
const service = index_1.register({
files,
pretty,
typeCheck,
transpileOnly,
ignore,
project,
skipIgnore,
preferTsExts,
logError,
skipProject,
compiler,
ignoreDiagnostics,
compilerOptions,
readFile: code ? readFileEval : undefined,
fileExists: code ? fileExistsEval : undefined
});
// Output project information.
if (version >= 2) {
console.log(`ts-node v${index_1.VERSION}`);
console.log(`node ${process.version}`);
console.log(`compiler v${service.ts.version}`);
process.exit(0);
}
// Require specified modules before start-up.
if (args['--require'])
Module._preloadModules(args['--require']);
// Prepend `ts-node` arguments to CLI for child processes.
process.execArgv.unshift(__filename, ...process.argv.slice(2, process.argv.length - args._.length));
process.argv = [process.argv[1]].concat(args._.length ? path_1.resolve(cwd, args._[0]) : []).concat(args._.slice(1));
// Execute the main contents (either eval, script or piped).
if (code) {
evalAndExit(code, isPrinted);
}
else {
if (args._.length) {
Module.runMain();
}
else {
// Piping of execution _only_ occurs when no other script is specified.
if (process.stdin.isTTY) {
startRepl();
}
else {
let code = '';
process.stdin.on('data', (chunk) => code += chunk);
process.stdin.on('end', () => evalAndExit(code, isPrinted));
}
}
}
/**
* Evaluate a script.
*/
function evalAndExit(code, isPrinted) {
const module = new Module(EVAL_FILENAME);
module.filename = EVAL_FILENAME;
module.paths = Module._nodeModulePaths(cwd);
global.__filename = EVAL_FILENAME;
global.__dirname = cwd;
global.exports = module.exports;
global.module = module;
global.require = module.require.bind(module);
let result;
try {
result = _eval(code);
}
catch (error) {
if (error instanceof index_1.TSError) {
console.error(error.diagnosticText);
process.exit(1);
}
throw error;
}
if (isPrinted) {
console.log(typeof result === 'string' ? result : util_1.inspect(result));
}
}
/**
* Evaluate the code snippet.
*/
function _eval(input) {
const lines = EVAL_INSTANCE.lines;
const isCompletion = !/\n$/.test(input);
const undo = appendEval(input);
let output;
try {
output = service.compile(EVAL_INSTANCE.input, EVAL_PATH, -lines);
}
catch (err) {
undo();
throw err;
}
// Use `diff` to check for new JavaScript to execute.
const changes = diff_1.diffLines(EVAL_INSTANCE.output, output);
if (isCompletion) {
undo();
}
else {
EVAL_INSTANCE.output = output;
}
return changes.reduce((result, change) => {
return change.added ? exec(change.value, EVAL_FILENAME) : result;
}, undefined);
}
/**
* Execute some code.
*/
function exec(code, filename) {
const script = new vm_1.Script(code, { filename: filename });
return script.runInThisContext();
}
/**
* Start a CLI REPL.
*/
function startRepl() {
const repl = repl_1.start({
prompt: '> ',
input: process.stdin,
output: process.stdout,
terminal: process.stdout.isTTY,
eval: replEval,
useGlobal: true
});
// Bookmark the point where we should reset the REPL state.
const resetEval = appendEval('');
function reset() {
resetEval();
// Hard fix for TypeScript forcing `Object.defineProperty(exports, ...)`.
exec('exports = module.exports', EVAL_FILENAME);
}
reset();
repl.on('reset', reset);
repl.defineCommand('type', {
help: 'Check the type of a TypeScript identifier',
action: function (identifier) {
if (!identifier) {
repl.displayPrompt();
return;
}
const undo = appendEval(identifier);
const { name, comment } = service.getTypeInfo(EVAL_INSTANCE.input, EVAL_PATH, EVAL_INSTANCE.input.length);
undo();
repl.outputStream.write(`${name}\n${comment ? `${comment}\n` : ''}`);
repl.displayPrompt();
}
});
}
/**
* Eval code from the REPL.
*/
function replEval(code, _context, _filename, callback) {
let err = null;
let result;
// TODO: Figure out how to handle completion here.
if (code === '.scope') {
callback(err);
return;
}
try {
result = _eval(code);
}
catch (error) {
if (error instanceof index_1.TSError) {
// Support recoverable compilations using >= node 6.
if (repl_1.Recoverable && isRecoverable(error)) {
err = new repl_1.Recoverable(error);
}
else {
console.error(error.diagnosticText);
}
}
else {
err = error;
}
}
callback(err, result);
}
/**
* Append to the eval instance and return an undo function.
*/
function appendEval(input) {
const undoInput = EVAL_INSTANCE.input;
const undoVersion = EVAL_INSTANCE.version;
const undoOutput = EVAL_INSTANCE.output;
const undoLines = EVAL_INSTANCE.lines;
// Handle ASI issues with TypeScript re-evaluation.
if (undoInput.charAt(undoInput.length - 1) === '\n' && /^\s*[\[\(\`]/.test(input) && !/;\s*$/.test(undoInput)) {
EVAL_INSTANCE.input = `${EVAL_INSTANCE.input.slice(0, -1)};\n`;
}
EVAL_INSTANCE.input += input;
EVAL_INSTANCE.lines += lineCount(input);
EVAL_INSTANCE.version++;
return function () {
EVAL_INSTANCE.input = undoInput;
EVAL_INSTANCE.output = undoOutput;
EVAL_INSTANCE.version = undoVersion;
EVAL_INSTANCE.lines = undoLines;
};
}
/**
* Count the number of lines.
*/
function lineCount(value) {
let count = 0;
for (const char of value) {
if (char === '\n') {
count++;
}
}
return count;
}
/**
* Get the file text, checking for eval first.
*/
function readFileEval(path) {
if (path === EVAL_PATH)
return EVAL_INSTANCE.input;
try {
return fs_1.readFileSync(path, 'utf8');
}
catch (err) { /* Ignore. */ }
}
/**
* Get whether the file exists.
*/
function fileExistsEval(path) {
if (path === EVAL_PATH)
return true;
try {
const stats = fs_1.statSync(path);
return stats.isFile() || stats.isFIFO();
}
catch (err) {
return false;
}
}
const RECOVERY_CODES = new Set([
1003,
1005,
1109,
1126,
1160,
1161,
2355 // "A function whose declared type is neither 'void' nor 'any' must return a value."
]);
/**
* Check if a function can recover gracefully.
*/
function isRecoverable(error) {
return error.diagnosticCodes.every(code => RECOVERY_CODES.has(code));
}
//# sourceMappingURL=bin.js.map

1
node_modules/ts-node/dist/bin.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

98
node_modules/ts-node/dist/index.d.ts generated vendored Normal file
View file

@ -0,0 +1,98 @@
import { BaseError } from 'make-error';
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;
formatDiagnostics: typeof _ts.formatDiagnostics;
formatDiagnosticsWithColorAndContext: typeof _ts.formatDiagnosticsWithColorAndContext;
}
/**
* Export the current version.
*/
export declare const VERSION: any;
/**
* Registration options.
*/
export interface Options {
pretty?: boolean | null;
typeCheck?: boolean | null;
transpileOnly?: boolean | null;
logError?: boolean | null;
files?: boolean | null;
compiler?: string;
ignore?: string[];
project?: string;
skipIgnore?: boolean | null;
skipProject?: boolean | null;
preferTsExts?: boolean | null;
compilerOptions?: object;
ignoreDiagnostics?: Array<number | string>;
readFile?: (path: string) => string | undefined;
fileExists?: (path: string) => boolean;
transformers?: _ts.CustomTransformers | ((p: _ts.Program) => _ts.CustomTransformers);
}
/**
* Information retrieved from type info check.
*/
export interface TypeInfo {
name: string;
comment: string;
}
/**
* Default register options.
*/
export declare const DEFAULTS: Options;
/**
* Split a string array of values.
*/
export declare function split(value: string | undefined): string[] | undefined;
/**
* Parse a string as JSON.
*/
export declare function parse(value: string | undefined): object | undefined;
/**
* Replace backslashes with forward slashes.
*/
export declare function normalizeSlashes(value: string): string;
/**
* TypeScript diagnostics error.
*/
export declare class TSError extends BaseError {
diagnosticText: string;
diagnosticCodes: number[];
name: string;
constructor(diagnosticText: string, diagnosticCodes: number[]);
}
/**
* Return type for registering `ts-node`.
*/
export interface Register {
cwd: string;
extensions: string[];
ts: TSCommon;
compile(code: string, fileName: string, lineOffset?: number): string;
getTypeInfo(code: string, fileName: string, position: number): TypeInfo;
}
/**
* Register TypeScript compiler.
*/
export declare function register(opts?: Options): Register;

449
node_modules/ts-node/dist/index.js generated vendored Normal file
View file

@ -0,0 +1,449 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const path_1 = require("path");
const sourceMapSupport = require("source-map-support");
const yn_1 = require("yn");
const make_error_1 = require("make-error");
const util = require("util");
/**
* @internal
*/
exports.INSPECT_CUSTOM = util.inspect.custom || 'inspect';
/**
* Debugging `ts-node`.
*/
const shouldDebug = yn_1.default(process.env.TS_NODE_DEBUG);
const debug = shouldDebug ? console.log.bind(console, 'ts-node') : () => undefined;
const debugFn = shouldDebug ?
(key, fn) => {
let i = 0;
return (x) => {
debug(key, x, ++i);
return fn(x);
};
} :
(_, fn) => fn;
/**
* Export the current version.
*/
exports.VERSION = require('../package.json').version;
/**
* Track the project information.
*/
class MemoryCache {
constructor(rootFileNames = []) {
this.rootFileNames = rootFileNames;
this.fileContents = new Map();
this.fileVersions = new Map();
for (const fileName of rootFileNames)
this.fileVersions.set(fileName, 1);
}
}
/**
* Default register options.
*/
exports.DEFAULTS = {
files: yn_1.default(process.env['TS_NODE_FILES']),
pretty: yn_1.default(process.env['TS_NODE_PRETTY']),
compiler: process.env['TS_NODE_COMPILER'],
compilerOptions: parse(process.env['TS_NODE_COMPILER_OPTIONS']),
ignore: split(process.env['TS_NODE_IGNORE']),
project: process.env['TS_NODE_PROJECT'],
skipIgnore: yn_1.default(process.env['TS_NODE_SKIP_IGNORE']),
skipProject: yn_1.default(process.env['TS_NODE_SKIP_PROJECT']),
preferTsExts: yn_1.default(process.env['TS_NODE_PREFER_TS_EXTS']),
ignoreDiagnostics: split(process.env['TS_NODE_IGNORE_DIAGNOSTICS']),
typeCheck: yn_1.default(process.env['TS_NODE_TYPE_CHECK']),
transpileOnly: yn_1.default(process.env['TS_NODE_TRANSPILE_ONLY']),
logError: yn_1.default(process.env['TS_NODE_LOG_ERROR'])
};
/**
* Default TypeScript compiler options required by `ts-node`.
*/
const TS_NODE_COMPILER_OPTIONS = {
sourceMap: true,
inlineSourceMap: false,
inlineSources: true,
declaration: false,
noEmit: false,
outDir: '$$ts-node$$'
};
/**
* Split a string array of values.
*/
function split(value) {
return typeof value === 'string' ? value.split(/ *, */g) : undefined;
}
exports.split = split;
/**
* Parse a string as JSON.
*/
function parse(value) {
return typeof value === 'string' ? JSON.parse(value) : undefined;
}
exports.parse = parse;
/**
* Replace backslashes with forward slashes.
*/
function normalizeSlashes(value) {
return value.replace(/\\/g, '/');
}
exports.normalizeSlashes = normalizeSlashes;
/**
* TypeScript diagnostics error.
*/
class TSError extends make_error_1.BaseError {
constructor(diagnosticText, diagnosticCodes) {
super(` Unable to compile TypeScript:\n${diagnosticText}`);
this.diagnosticText = diagnosticText;
this.diagnosticCodes = diagnosticCodes;
this.name = 'TSError';
}
/**
* @internal
*/
[exports.INSPECT_CUSTOM]() {
return this.diagnosticText;
}
}
exports.TSError = TSError;
/**
* Cached fs operation wrapper.
*/
function cachedLookup(fn) {
const cache = new Map();
return (arg) => {
if (!cache.has(arg)) {
cache.set(arg, fn(arg));
}
return cache.get(arg);
};
}
/**
* Register TypeScript compiler.
*/
function register(opts = {}) {
const options = Object.assign({}, exports.DEFAULTS, opts);
const originalJsHandler = require.extensions['.js']; // tslint:disable-line
const ignoreDiagnostics = [
6059,
18002,
18003,
...(options.ignoreDiagnostics || [])
].map(Number);
const ignore = options.skipIgnore ? [] : (options.ignore || ['/node_modules/']).map(str => new RegExp(str));
// Require the TypeScript compiler and configuration.
const cwd = process.cwd();
const typeCheck = options.typeCheck === true || options.transpileOnly !== true;
const compiler = require.resolve(options.compiler || 'typescript', { paths: [cwd, __dirname] });
const ts = require(compiler);
const transformers = options.transformers || undefined;
const readFile = options.readFile || ts.sys.readFile;
const fileExists = options.fileExists || ts.sys.fileExists;
const config = readConfig(cwd, ts, fileExists, readFile, options);
const configDiagnosticList = filterDiagnostics(config.errors, ignoreDiagnostics);
const extensions = ['.ts'];
const outputCache = new Map();
const diagnosticHost = {
getNewLine: () => ts.sys.newLine,
getCurrentDirectory: () => cwd,
getCanonicalFileName: (path) => path
};
// Install source map support and read from memory cache.
sourceMapSupport.install({
environment: 'node',
retrieveFile(path) {
return outputCache.get(path) || '';
}
});
const formatDiagnostics = process.stdout.isTTY || options.pretty
? ts.formatDiagnosticsWithColorAndContext
: ts.formatDiagnostics;
function createTSError(diagnostics) {
const diagnosticText = formatDiagnostics(diagnostics, diagnosticHost);
const diagnosticCodes = diagnostics.map(x => x.code);
return new TSError(diagnosticText, diagnosticCodes);
}
function reportTSError(configDiagnosticList) {
const error = createTSError(configDiagnosticList);
if (options.logError) {
// Print error in red color and continue execution.
console.error('\x1b[31m%s\x1b[0m', error);
}
else {
// Throw error and exit the script.
throw error;
}
}
// Render the configuration errors.
if (configDiagnosticList.length)
reportTSError(configDiagnosticList);
// Enable additional extensions when JSX or `allowJs` is enabled.
if (config.options.jsx)
extensions.push('.tsx');
if (config.options.allowJs)
extensions.push('.js');
if (config.options.jsx && config.options.allowJs)
extensions.push('.jsx');
/**
* Get the extension for a transpiled file.
*/
const getExtension = config.options.jsx === ts.JsxEmit.Preserve ?
((path) => /\.[tj]sx$/.test(path) ? '.jsx' : '.js') :
((_) => '.js');
/**
* Create the basic required function using transpile mode.
*/
let getOutput;
let getTypeInfo;
// Use full language services when the fast option is disabled.
if (typeCheck) {
const memoryCache = new MemoryCache(config.fileNames);
const cachedReadFile = cachedLookup(debugFn('readFile', readFile));
const getCustomTransformers = () => {
if (typeof transformers === 'function') {
const program = service.getProgram();
return program ? transformers(program) : undefined;
}
return transformers;
};
// Create the compiler host for type checking.
const serviceHost = {
getScriptFileNames: () => memoryCache.rootFileNames,
getScriptVersion: (fileName) => {
const version = memoryCache.fileVersions.get(fileName);
return version === undefined ? '' : version.toString();
},
getScriptSnapshot(fileName) {
let contents = memoryCache.fileContents.get(fileName);
// Read contents into TypeScript memory cache.
if (contents === undefined) {
contents = cachedReadFile(fileName);
if (contents === undefined)
return;
memoryCache.fileVersions.set(fileName, 1);
memoryCache.fileContents.set(fileName, contents);
}
return ts.ScriptSnapshot.fromString(contents);
},
readFile: cachedReadFile,
readDirectory: cachedLookup(debugFn('readDirectory', ts.sys.readDirectory)),
getDirectories: cachedLookup(debugFn('getDirectories', ts.sys.getDirectories)),
fileExists: cachedLookup(debugFn('fileExists', fileExists)),
directoryExists: cachedLookup(debugFn('directoryExists', ts.sys.directoryExists)),
getNewLine: () => ts.sys.newLine,
useCaseSensitiveFileNames: () => ts.sys.useCaseSensitiveFileNames,
getCurrentDirectory: () => cwd,
getCompilationSettings: () => config.options,
getDefaultLibFileName: () => ts.getDefaultLibFilePath(config.options),
getCustomTransformers: getCustomTransformers,
writeFile: ts.sys.writeFile
};
const registry = ts.createDocumentRegistry(ts.sys.useCaseSensitiveFileNames, cwd);
const service = ts.createLanguageService(serviceHost, registry);
// Set the file contents into cache manually.
const updateMemoryCache = (contents, fileName) => {
const fileVersion = memoryCache.fileVersions.get(fileName) || 0;
// Add to `rootFiles` when discovered for the first time.
if (fileVersion === 0)
memoryCache.rootFileNames.push(fileName);
// Avoid incrementing cache when nothing has changed.
if (memoryCache.fileContents.get(fileName) === contents)
return;
memoryCache.fileVersions.set(fileName, fileVersion + 1);
memoryCache.fileContents.set(fileName, contents);
};
getOutput = (code, fileName) => {
updateMemoryCache(code, fileName);
const output = service.getEmitOutput(fileName);
// Get the relevant diagnostics - this is 3x faster than `getPreEmitDiagnostics`.
const diagnostics = service.getSemanticDiagnostics(fileName)
.concat(service.getSyntacticDiagnostics(fileName));
const diagnosticList = filterDiagnostics(diagnostics, ignoreDiagnostics);
if (diagnosticList.length)
reportTSError(diagnosticList);
if (output.emitSkipped) {
throw new TypeError(`${path_1.relative(cwd, fileName)}: Emit skipped`);
}
// Throw an error when requiring `.d.ts` files.
if (output.outputFiles.length === 0) {
throw new TypeError('Unable to require `.d.ts` file.\n' +
'This is usually the result of a faulty configuration or import. ' +
'Make sure there is a `.js`, `.json` or another executable extension and ' +
'loader (attached before `ts-node`) available alongside ' +
`\`${path_1.basename(fileName)}\`.`);
}
return [output.outputFiles[1].text, output.outputFiles[0].text];
};
getTypeInfo = (code, fileName, position) => {
updateMemoryCache(code, fileName);
const info = service.getQuickInfoAtPosition(fileName, position);
const name = ts.displayPartsToString(info ? info.displayParts : []);
const comment = ts.displayPartsToString(info ? info.documentation : []);
return { name, comment };
};
}
else {
if (typeof transformers === 'function') {
throw new TypeError('Transformers function is unavailable in "--transpile-only"');
}
getOutput = (code, fileName) => {
const result = ts.transpileModule(code, {
fileName,
transformers,
compilerOptions: config.options,
reportDiagnostics: true
});
const diagnosticList = result.diagnostics ?
filterDiagnostics(result.diagnostics, ignoreDiagnostics) :
[];
if (diagnosticList.length)
reportTSError(configDiagnosticList);
return [result.outputText, result.sourceMapText];
};
getTypeInfo = () => {
throw new TypeError('Type information is unavailable in "--transpile-only"');
};
}
// Create a simple TypeScript compiler proxy.
function compile(code, fileName, lineOffset = 0) {
const [value, sourceMap] = getOutput(code, fileName, lineOffset);
const output = updateOutput(value, fileName, sourceMap, getExtension);
outputCache.set(fileName, output);
return output;
}
const register = { cwd, compile, getTypeInfo, extensions, ts };
// Register the extensions.
registerExtensions(options.preferTsExts, extensions, ignore, register, originalJsHandler);
return register;
}
exports.register = register;
/**
* Check if the filename should be ignored.
*/
function shouldIgnore(filename, ignore) {
const relname = normalizeSlashes(filename);
return ignore.some(x => x.test(relname));
}
/**
* "Refreshes" an extension on `require.extentions`.
*
* @param {string} ext
*/
function reorderRequireExtension(ext) {
const old = require.extensions[ext]; // tslint:disable-line
delete require.extensions[ext]; // tslint:disable-line
require.extensions[ext] = old; // tslint:disable-line
}
/**
* Register the extensions to support when importing files.
*/
function registerExtensions(preferTsExts, extensions, ignore, register, originalJsHandler) {
// Register new extensions.
for (const ext of extensions) {
registerExtension(ext, ignore, register, originalJsHandler);
}
if (preferTsExts) {
// tslint:disable-next-line
const preferredExtensions = new Set([...extensions, ...Object.keys(require.extensions)]);
for (const ext of preferredExtensions)
reorderRequireExtension(ext);
}
}
/**
* Register the extension for node.
*/
function registerExtension(ext, ignore, register, originalHandler) {
const old = require.extensions[ext] || originalHandler; // tslint:disable-line
require.extensions[ext] = function (m, filename) {
if (shouldIgnore(filename, ignore)) {
return old(m, filename);
}
const _compile = m._compile;
m._compile = function (code, fileName) {
debug('module._compile', fileName);
return _compile.call(this, register.compile(code, fileName), fileName);
};
return old(m, filename);
};
}
/**
* Do post-processing on config options to support `ts-node`.
*/
function fixConfig(ts, config) {
// Delete options that *should not* be passed through.
delete config.options.out;
delete config.options.outFile;
delete config.options.composite;
delete config.options.declarationDir;
delete config.options.declarationMap;
delete config.options.emitDeclarationOnly;
delete config.options.tsBuildInfoFile;
delete config.options.incremental;
// Target ES5 output by default (instead of ES3).
if (config.options.target === undefined) {
config.options.target = ts.ScriptTarget.ES5;
}
// Target CommonJS modules by default (instead of magically switching to ES6 when the target is ES6).
if (config.options.module === undefined) {
config.options.module = ts.ModuleKind.CommonJS;
}
return config;
}
/**
* Load TypeScript configuration.
*/
function readConfig(cwd, ts, fileExists, readFile, options) {
let config = { compilerOptions: {} };
let basePath = normalizeSlashes(cwd);
let configFileName = undefined;
// Read project configuration when available.
if (!options.skipProject) {
configFileName = options.project
? normalizeSlashes(path_1.resolve(cwd, options.project))
: ts.findConfigFile(normalizeSlashes(cwd), fileExists);
if (configFileName) {
const result = ts.readConfigFile(configFileName, readFile);
// Return diagnostics.
if (result.error) {
return { errors: [result.error], fileNames: [], options: {} };
}
config = result.config;
basePath = normalizeSlashes(path_1.dirname(configFileName));
}
}
// Remove resolution of "files".
if (!options.files) {
config.files = [];
config.include = [];
}
// Override default configuration options `ts-node` requires.
config.compilerOptions = Object.assign({}, config.compilerOptions, options.compilerOptions, TS_NODE_COMPILER_OPTIONS);
return fixConfig(ts, ts.parseJsonConfigFileContent(config, ts.sys, basePath, undefined, configFileName));
}
/**
* Update the output remapping the source map.
*/
function updateOutput(outputText, fileName, sourceMap, getExtension) {
const base64Map = Buffer.from(updateSourceMap(sourceMap, fileName), 'utf8').toString('base64');
const sourceMapContent = `data:application/json;charset=utf-8;base64,${base64Map}`;
const sourceMapLength = `${path_1.basename(fileName)}.map`.length + (getExtension(fileName).length - path_1.extname(fileName).length);
return outputText.slice(0, -sourceMapLength) + sourceMapContent;
}
/**
* Update the source map contents for improved output.
*/
function updateSourceMap(sourceMapText, fileName) {
const sourceMap = JSON.parse(sourceMapText);
sourceMap.file = fileName;
sourceMap.sources = [fileName];
delete sourceMap.sourceRoot;
return JSON.stringify(sourceMap);
}
/**
* Filter diagnostics.
*/
function filterDiagnostics(diagnostics, ignore) {
return diagnostics.filter(x => ignore.indexOf(x.code) === -1);
}
//# sourceMappingURL=index.js.map

1
node_modules/ts-node/dist/index.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

1
node_modules/ts-node/dist/index.spec.d.ts generated vendored Normal file
View file

@ -0,0 +1 @@
export {};

298
node_modules/ts-node/dist/index.spec.js generated vendored Normal file
View file

@ -0,0 +1,298 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const chai_1 = require("chai");
const child_process_1 = require("child_process");
const path_1 = require("path");
const semver = require("semver");
const ts = require("typescript");
const proxyquire = require("proxyquire");
const index_1 = require("./index");
const TEST_DIR = path_1.join(__dirname, '../tests');
const EXEC_PATH = path_1.join(__dirname, '../dist/bin');
const PROJECT = path_1.join(TEST_DIR, semver.gte(ts.version, '2.5.0') ? 'tsconfig.json5' : 'tsconfig.json');
const BIN_EXEC = `node "${EXEC_PATH}" --project "${PROJECT}"`;
const SOURCE_MAP_REGEXP = /\/\/# sourceMappingURL=data:application\/json;charset=utf\-8;base64,[\w\+]+=*$/;
describe('ts-node', function () {
this.timeout(10000);
it('should export the correct version', function () {
chai_1.expect(index_1.VERSION).to.equal(require('../package.json').version);
});
describe('cli', function () {
this.slow(1000);
it('should execute cli', function (done) {
child_process_1.exec(`${BIN_EXEC} tests/hello-world`, function (err, stdout) {
chai_1.expect(err).to.equal(null);
chai_1.expect(stdout).to.equal('Hello, world!\n');
return done();
});
});
it('should register via cli', function (done) {
child_process_1.exec(`node -r ../register hello-world.ts`, {
cwd: TEST_DIR
}, function (err, stdout) {
chai_1.expect(err).to.equal(null);
chai_1.expect(stdout).to.equal('Hello, world!\n');
return done();
});
});
it('should execute cli with absolute path', function (done) {
child_process_1.exec(`${BIN_EXEC} "${path_1.join(TEST_DIR, 'hello-world')}"`, function (err, stdout) {
chai_1.expect(err).to.equal(null);
chai_1.expect(stdout).to.equal('Hello, world!\n');
return done();
});
});
it('should print scripts', function (done) {
child_process_1.exec(`${BIN_EXEC} -pe "import { example } from './tests/complex/index';example()"`, function (err, stdout) {
chai_1.expect(err).to.equal(null);
chai_1.expect(stdout).to.equal('example\n');
return done();
});
});
if (semver.gte(ts.version, '1.8.0')) {
it('should allow js', function (done) {
child_process_1.exec([
BIN_EXEC,
'-O "{\\\"allowJs\\\":true}"',
'-pe "import { main } from \'./tests/allow-js/run\';main()"'
].join(' '), function (err, stdout) {
chai_1.expect(err).to.equal(null);
chai_1.expect(stdout).to.equal('hello world\n');
return done();
});
});
it('should include jsx when `allow-js` true', function (done) {
child_process_1.exec([
BIN_EXEC,
'-O "{\\\"allowJs\\\":true}"',
'-pe "import { Foo2 } from \'./tests/allow-js/with-jsx\'; Foo2.sayHi()"'
].join(' '), function (err, stdout) {
chai_1.expect(err).to.equal(null);
chai_1.expect(stdout).to.equal('hello world\n');
return done();
});
});
}
it('should eval code', function (done) {
child_process_1.exec(`${BIN_EXEC} -e "import * as m from './tests/module';console.log(m.example('test'))"`, function (err, stdout) {
chai_1.expect(err).to.equal(null);
chai_1.expect(stdout).to.equal('TEST\n');
return done();
});
});
it('should import empty files', function (done) {
child_process_1.exec(`${BIN_EXEC} -e "import './tests/empty'"`, function (err, stdout) {
chai_1.expect(err).to.equal(null);
chai_1.expect(stdout).to.equal('');
return done();
});
});
it('should throw errors', function (done) {
child_process_1.exec(`${BIN_EXEC} -e "import * as m from './tests/module';console.log(m.example(123))"`, function (err) {
if (err === null) {
return done('Command was expected to fail, but it succeeded.');
}
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();
});
});
it('should be able to ignore diagnostic', function (done) {
child_process_1.exec(`${BIN_EXEC} --ignore-diagnostics 2345 -e "import * as m from './tests/module';console.log(m.example(123))"`, function (err) {
if (err === null) {
return done('Command was expected to fail, but it succeeded.');
}
chai_1.expect(err.message).to.match(/TypeError: (?:(?:undefined|foo\.toUpperCase) is not a function|.*has no method \'toUpperCase\')/);
return done();
});
});
it('should work with source maps', function (done) {
child_process_1.exec(`${BIN_EXEC} tests/throw`, function (err) {
if (err === null) {
return done('Command was expected to fail, but it succeeded.');
}
chai_1.expect(err.message).to.contain([
`${path_1.join(__dirname, '../tests/throw.ts')}:3`,
' bar () { throw new Error(\'this is a demo\') }',
' ^',
'Error: this is a demo'
].join('\n'));
return done();
});
});
it.skip('eval should work with source maps', function (done) {
child_process_1.exec(`${BIN_EXEC} -pe "import './tests/throw'"`, function (err) {
if (err === null) {
return done('Command was expected to fail, but it succeeded.');
}
chai_1.expect(err.message).to.contain([
`${path_1.join(__dirname, '../tests/throw.ts')}:3`,
' bar () { throw new Error(\'this is a demo\') }',
' ^'
].join('\n'));
return done();
});
});
it('should support transpile only mode', function (done) {
child_process_1.exec(`${BIN_EXEC} --transpile-only -pe "x"`, function (err) {
if (err === null) {
return done('Command was expected to fail, but it succeeded.');
}
chai_1.expect(err.message).to.contain('ReferenceError: x is not defined');
return done();
});
});
it('should pipe into `ts-node` and evaluate', function (done) {
const cp = child_process_1.exec(BIN_EXEC, function (err, stdout) {
chai_1.expect(err).to.equal(null);
chai_1.expect(stdout).to.equal('hello\n');
return done();
});
cp.stdin.end("console.log('hello')");
});
it('should pipe into `ts-node`', function (done) {
const cp = child_process_1.exec(`${BIN_EXEC} -p`, function (err, stdout) {
chai_1.expect(err).to.equal(null);
chai_1.expect(stdout).to.equal('true\n');
return done();
});
cp.stdin.end('true');
});
it('should pipe into an eval script', function (done) {
const cp = child_process_1.exec(`${BIN_EXEC} --transpile-only -pe 'process.stdin.isTTY'`, function (err, stdout) {
chai_1.expect(err).to.equal(null);
chai_1.expect(stdout).to.equal('undefined\n');
return done();
});
cp.stdin.end('true');
});
it('should support require flags', function (done) {
child_process_1.exec(`${BIN_EXEC} -r ./tests/hello-world -pe "console.log('success')"`, function (err, stdout) {
chai_1.expect(err).to.equal(null);
chai_1.expect(stdout).to.equal('Hello, world!\nsuccess\nundefined\n');
return done();
});
});
it('should support require from node modules', function (done) {
child_process_1.exec(`${BIN_EXEC} -r typescript -e "console.log('success')"`, function (err, stdout) {
chai_1.expect(err).to.equal(null);
chai_1.expect(stdout).to.equal('success\n');
return done();
});
});
it.skip('should use source maps with react tsx', function (done) {
child_process_1.exec(`${BIN_EXEC} -r ./tests/emit-compiled.ts tests/jsx-react.tsx`, function (err, stdout) {
chai_1.expect(err).to.equal(null);
chai_1.expect(stdout).to.equal('todo');
return done();
});
});
it('should allow custom typings', function (done) {
child_process_1.exec(`${BIN_EXEC} tests/custom-types`, function (err, stdout) {
chai_1.expect(err).to.match(/Error: Cannot find module 'does-not-exist'/);
return done();
});
});
it('should preserve `ts-node` context with child process', function (done) {
child_process_1.exec(`${BIN_EXEC} tests/child-process`, function (err, stdout) {
chai_1.expect(err).to.equal(null);
chai_1.expect(stdout).to.equal('Hello, world!\n');
return done();
});
});
it('should import js before ts by default', function (done) {
child_process_1.exec(`${BIN_EXEC} tests/import-order/compiled`, function (err, stdout) {
chai_1.expect(err).to.equal(null);
chai_1.expect(stdout).to.equal('Hello, JavaScript!\n');
return done();
});
});
it('should import ts before js when --prefer-ts-exts flag is present', function (done) {
child_process_1.exec(`${BIN_EXEC} --prefer-ts-exts tests/import-order/compiled`, function (err, stdout) {
chai_1.expect(err).to.equal(null);
chai_1.expect(stdout).to.equal('Hello, TypeScript!\n');
return done();
});
});
it('should import ts before js when TS_NODE_PREFER_TS_EXTS env is present', function (done) {
child_process_1.exec(`${BIN_EXEC} tests/import-order/compiled`, { env: Object.assign(Object.assign({}, process.env), { TS_NODE_PREFER_TS_EXTS: 'true' }) }, function (err, stdout) {
chai_1.expect(err).to.equal(null);
chai_1.expect(stdout).to.equal('Hello, TypeScript!\n');
return done();
});
});
it('should ignore .d.ts files', function (done) {
child_process_1.exec(`${BIN_EXEC} tests/import-order/importer`, function (err, stdout) {
chai_1.expect(err).to.equal(null);
chai_1.expect(stdout).to.equal('Hello, World!\n');
return done();
});
});
});
describe('register', function () {
index_1.register({
project: PROJECT,
compilerOptions: {
jsx: 'preserve'
}
});
it('should be able to require typescript', function () {
const m = require('../tests/module');
chai_1.expect(m.example('foo')).to.equal('FOO');
});
it('should compile through js and ts', function () {
const m = require('../tests/complex');
chai_1.expect(m.example()).to.equal('example');
});
it('should work with proxyquire', function () {
const m = proxyquire('../tests/complex', {
'./example': 'hello'
});
chai_1.expect(m.example()).to.equal('hello');
});
it('should work with `require.cache`', function () {
const { example1, example2 } = require('../tests/require-cache');
chai_1.expect(example1).to.not.equal(example2);
});
it('should use source maps', function (done) {
try {
require('../tests/throw');
}
catch (error) {
chai_1.expect(error.stack).to.contain([
'Error: this is a demo',
` at Foo.bar (${path_1.join(__dirname, '../tests/throw.ts')}:3:18)`
].join('\n'));
done();
}
});
describe('JSX preserve', () => {
let old = require.extensions['.tsx']; // tslint:disable-line
let compiled;
before(function () {
require.extensions['.tsx'] = (m, fileName) => {
const _compile = m._compile;
m._compile = (code, fileName) => {
compiled = code;
return _compile.call(this, code, fileName);
};
return old(m, fileName);
};
});
after(function () {
require.extensions['.tsx'] = old; // tslint:disable-line
});
it('should use source maps', function (done) {
try {
require('../tests/with-jsx.tsx');
}
catch (error) {
chai_1.expect(error.stack).to.contain('SyntaxError: Unexpected token <\n');
}
chai_1.expect(compiled).to.match(SOURCE_MAP_REGEXP);
done();
});
});
});
});
//# sourceMappingURL=index.spec.js.map

1
node_modules/ts-node/dist/index.spec.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

1
node_modules/ts-node/node_modules/.bin/tsc generated vendored Symbolic link
View file

@ -0,0 +1 @@
../../../typescript/bin/tsc

1
node_modules/ts-node/node_modules/.bin/tsserver generated vendored Symbolic link
View file

@ -0,0 +1 @@
../../../typescript/bin/tsserver

79
node_modules/ts-node/package.json generated vendored Normal file
View file

@ -0,0 +1,79 @@
{
"name": "ts-node",
"version": "8.4.1",
"description": "TypeScript execution environment and REPL for node.js, with source map support",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"bin": {
"ts-node": "dist/bin.js"
},
"files": [
"dist/",
"register/",
"LICENSE"
],
"scripts": {
"lint": "tslint \"src/**/*.ts\" --project tsconfig.json",
"build": "rimraf dist && tsc",
"test-spec": "mocha dist/**/*.spec.js -R spec --bail",
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- \"dist/**/*.spec.js\" -R spec --bail",
"test": "npm run build && npm run lint && npm run test-cov",
"prepare": "npm run build"
},
"engines": {
"node": ">=4.2.0"
},
"repository": {
"type": "git",
"url": "git://github.com/TypeStrong/ts-node.git"
},
"keywords": [
"typescript",
"node",
"runtime",
"environment",
"ts",
"compiler"
],
"author": {
"name": "Blake Embrey",
"email": "hello@blakeembrey.com",
"url": "http://blakeembrey.me"
},
"license": "MIT",
"bugs": {
"url": "https://github.com/TypeStrong/ts-node/issues"
},
"homepage": "https://github.com/TypeStrong/ts-node",
"devDependencies": {
"@types/chai": "^4.0.4",
"@types/diff": "^4.0.2",
"@types/mocha": "^5.0.0",
"@types/node": "^12.0.2",
"@types/proxyquire": "^1.3.28",
"@types/react": "^16.0.2",
"@types/semver": "^6.0.0",
"@types/source-map-support": "^0.5.0",
"chai": "^4.0.1",
"istanbul": "^0.4.0",
"mocha": "^6.1.4",
"ntypescript": "^1.201507091536.1",
"proxyquire": "^2.0.0",
"react": "^16.0.0",
"rimraf": "^2.5.4",
"semver": "^6.1.0",
"tslint": "^5.11.0",
"tslint-config-standard": "^8.0.1",
"typescript": "^3.6.3"
},
"peerDependencies": {
"typescript": ">=2.0"
},
"dependencies": {
"arg": "^4.1.0",
"diff": "^4.0.1",
"make-error": "^1.1.1",
"source-map-support": "^0.5.6",
"yn": "^3.0.0"
}
}

1
node_modules/ts-node/register/index.js generated vendored Normal file
View file

@ -0,0 +1 @@
require('../').register()

3
node_modules/ts-node/register/transpile-only.js generated vendored Normal file
View file

@ -0,0 +1,3 @@
require('../').register({
transpileOnly: true
})

3
node_modules/ts-node/register/type-check.js generated vendored Normal file
View file

@ -0,0 +1,3 @@
require('../').register({
typeCheck: true
})