feat(cache): enable --nocache cli option

This commit is contained in:
Philipp Kunz 2018-07-03 14:40:58 +02:00
parent 42f2f132f1
commit 51808f230a
6 changed files with 24 additions and 550 deletions

15
dist/index.js vendored
View File

@ -1,14 +1,19 @@
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const path = require("path"); const path = require("path");
const tsNode = require("./tsnode"); const tsNode = require("ts-node");
tsNode.register({ const defaultTsNodeOptions = {
compilerOptions: { compilerOptions: {
lib: ['es2016', 'es2017'] lib: ['es2016', 'es2017'],
target: 'es2015',
}, },
skipIgnore: true, skipIgnore: true,
cacheDirectory: path.join(__dirname, '../tscache') cacheDirectory: path.join(__dirname, '../tscache')
}); };
if (process.argv.includes('--nocache')) {
defaultTsNodeOptions.cache = false;
}
tsNode.register(defaultTsNodeOptions);
if (process.env.CLI_CALL_TSRUN) { if (process.env.CLI_CALL_TSRUN) {
// contents of argv array // contents of argv array
// process.argv[0] -> node Executable // process.argv[0] -> node Executable
@ -17,4 +22,4 @@ if (process.env.CLI_CALL_TSRUN) {
const pathToLoad = path.join(process.cwd(), pathToTsFile); const pathToLoad = path.join(process.cwd(), pathToTsFile);
Promise.resolve().then(() => require(pathToLoad)); Promise.resolve().then(() => require(pathToLoad));
} }
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLDZCQUE2QjtBQUM3QixtQ0FBbUM7QUFFbkMsTUFBTSxDQUFDLFFBQVEsQ0FBQztJQUNkLGVBQWUsRUFBRTtRQUNmLEdBQUcsRUFBRSxDQUFFLFFBQVEsRUFBRSxRQUFRLENBQUU7S0FDNUI7SUFDRCxVQUFVLEVBQUUsSUFBSTtJQUNoQixjQUFjLEVBQUUsSUFBSSxDQUFDLElBQUksQ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UFHLENBQUMsY0FBYyxFQUFFO0lBQzlCLHlCQUF5QjtJQUN6QixxQ0FBcUM7SUFDckMsc0NBQXNDO0lBQ3RDLE1BQU0sWUFBWSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FBQyxDQUFDLENBQUE7SUFFcEMsTUFBTSxVQUFVLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQyxPQUFPLENBQUMsR0FBRyxFQUFFLEVBQUUsWUFBWSxDQUFDLENBQUM7SUFDMUQscUNBQU8sVUFBVSxHQUFFO0NBQ3BCIn0=

99
dist/tsnode.d.ts vendored
View File

@ -1,99 +0,0 @@
import { BaseError } from 'make-error';
import * as _ts from 'typescript';
/**
* @internal
*/
export declare const INSPECT_CUSTOM: string | 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;
files?: boolean | null;
cache?: boolean | null;
cacheDirectory?: string;
compiler?: string;
ignore?: string | string[];
project?: string;
skipIgnore?: boolean | null;
skipProject?: boolean | null;
compilerOptions?: object;
ignoreDiagnostics?: number | string | Array<number | string>;
readFile?: (path: string) => string | undefined;
fileExists?: (path: string) => boolean;
transformers?: _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[];
/**
* 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[];
cachedir: 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;

439
dist/tsnode.js vendored

File diff suppressed because one or more lines are too long

6
package-lock.json generated
View File

@ -13,9 +13,9 @@
} }
}, },
"@types/node": { "@types/node": {
"version": "10.3.0", "version": "10.5.1",
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.3.0.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-10.5.1.tgz",
"integrity": "sha512-hWzNviaVFIr1TqcRA8ou49JaSHp+Rfabmnqg2kNvusKqLhPU0rIsGPUj5WJJ7ld4Bb7qdgLmIhLfCD1qS08IVA==" "integrity": "sha512-AFLl1IALIuyt6oK4AYZsgWVJ/5rnyzQWud7IebaZWWV3YmgtPZkQmYio9R5Ze/2pdd7XfqF5bP+hWS11mAKoOQ=="
}, },
"@types/vinyl": { "@types/vinyl": {
"version": "2.0.2", "version": "2.0.2",

View File

@ -16,7 +16,7 @@
"postinstall": "(node ./cli.js scripts/postinstall.ts)" "postinstall": "(node ./cli.js scripts/postinstall.ts)"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^10.3.0" "@types/node": "^10.5.1"
}, },
"dependencies": { "dependencies": {
"smartfile": "^4.2.28", "smartfile": "^4.2.28",

View File

@ -1,13 +1,20 @@
import * as path from 'path'; import * as path from 'path';
import * as tsNode from 'ts-node'; import * as tsNode from 'ts-node';
tsNode.register({ const defaultTsNodeOptions: tsNode.Options = {
compilerOptions: { compilerOptions: {
lib: [ 'es2016', 'es2017' ] lib: ['es2016','es2017'],
target: 'es2015',
}, },
skipIgnore: true, skipIgnore: true,
cacheDirectory: path.join(__dirname, '../tscache') cacheDirectory: path.join(__dirname, '../tscache')
}); }
if (process.argv.includes('--nocache')) {
defaultTsNodeOptions.cache = false;
}
tsNode.register(defaultTsNodeOptions);
if (process.env.CLI_CALL_TSRUN) { if (process.env.CLI_CALL_TSRUN) {
// contents of argv array // contents of argv array