本文整理汇总了TypeScript中source-map-support.install函数的典型用法代码示例。如果您正苦于以下问题:TypeScript install函数的具体用法?TypeScript install怎么用?TypeScript install使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了install函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: enableSourceMaps
export function enableSourceMaps() {
sourceMapSupport.install({
environment: 'node',
handleUncaughtExceptions: false,
retrieveSourceMap,
})
const AnyError = Error as any
// We want to keep `source-map-support`s `prepareStackTrace` around to use
// later, but our cheaper `prepareStackTrace` should be the default.
prepareStackTraceWithSourceMap = AnyError.prepareStackTrace
AnyError.prepareStackTrace = prepareStackTrace
}
示例2: installSourceMapSupport
function installSourceMapSupport(filesystem: typeof fs) {
sourceMapSupport.install({
// NOTE: If https://github.com/evanw/node-source-map-support/pull/149
// lands we can be less aggressive and explicitly invalidate the source
// map cache when Webpack recompiles.
emptyCacheBetweenOperations: true,
retrieveFile(source) {
try {
return filesystem.readFileSync(source, "utf8");
} catch (ex) {
// Doesn't exist
return "";
}
}
});
}
示例3: run
export async function run(_testRoot: string, callback: TestRunnerCallback) {
// Enable source map support. This is done in the original Mocha test runner,
// so do it here. It is not clear if this is having any effect.
sourceMapSupport.install();
// Forward logging from Jest to the Debug Console.
forwardStdoutStderrStreams();
try {
const { results } = await runCLI(jestConfig as any, [rootDir]);
const failures = collectTestFailureMessages(results);
if (failures.length > 0) {
callback(null, failures);
return;
}
callback(null);
} catch (e) {
callback(e);
}
}
示例4:
'use strict';
import * as fs from 'fs';
import * as path from 'path';
import * as util from 'util';
import * as P from 'parsimmon';
import * as glob from 'glob';
import * as sms from 'source-map-support';
import * as chai from 'chai';
let assert = chai.assert;
sms.install();
import * as DH from '../../src/';
let testDir = path.resolve(__dirname, '..');
let repoDir = path.join(testDir, '..', 'repo');
describe('full repo', () => {
if (!fs.existsSync(repoDir)) {
return;
}
let files = glob.sync('*/*.d.ts', {
cwd: repoDir
});
files.sort();
示例5: Thinker
import * as readLine from "readline";
import RequestScope from "../core/communication/RequestScope";
import Thinker from "../core/think/Thinker";
import DataStore from "../core/data/DataStore";
import User from "../core/data/model/User";
import * as smp from "source-map-support";
smp.install();
const data = DataStore.createFromSettings();
const thinker = new Thinker();
data.open();
const user = new User();
data.save(user).then( () => {
let reader = readLine.createInterface({
input: process.stdin,
output: process.stdout
});
reader.on('line', function (line) {
const rs = new RequestScope(user.id, line,new Date, 0 );
thinker.think(rs, data)
.then(() => {
for(let i in rs.meshinatorMessages){
console.log(rs.meshinatorMessages[i]);
}
})
.catch( e => console.log(e));
});
process.stdin.on('end', function () {
示例6: runTestInternal
//.........这里部分代码省略.........
changedFiles: context && context.changedFiles,
collectCoverage: globalConfig.collectCoverage,
collectCoverageFrom: globalConfig.collectCoverageFrom,
collectCoverageOnlyFrom: globalConfig.collectCoverageOnlyFrom,
});
const start = Date.now();
const sourcemapOptions: SourceMapOptions = {
environment: 'node',
handleUncaughtExceptions: false,
retrieveSourceMap: source => {
const sourceMaps = runtime && runtime.getSourceMaps();
const sourceMapSource = sourceMaps && sourceMaps[source];
if (sourceMapSource) {
try {
return {
map: JSON.parse(fs.readFileSync(sourceMapSource, 'utf8')),
url: source,
};
} catch (e) {}
}
return null;
},
};
// For tests
runtime
.requireInternalModule(
require.resolve('source-map-support'),
'source-map-support',
)
.install(sourcemapOptions);
// For runtime errors
sourcemapSupport.install(sourcemapOptions);
if (
environment.global &&
environment.global.process &&
environment.global.process.exit
) {
const realExit = environment.global.process.exit;
environment.global.process.exit = function exit(...args: Array<any>) {
const error = new ErrorWithStack(
`process.exit called with "${args.join(', ')}"`,
exit,
);
const formattedError = formatExecError(
error,
config,
{noStackTrace: false},
undefined,
true,
);
process.stderr.write(formattedError);
return realExit(...args);
};
}
try {
示例7:
import fs from 'fs'
import { app, screen, ipcMain, BrowserWindow } from 'electron'
import DB from 'sqlite3-helper/no-generators'
import { install as initSourceMapSupport } from 'source-map-support'
import { start as initPrettyError } from 'pretty-error'
import MainMenu from './MainMenu'
// import Usb from './usb'
import config from '../common/config'
import Watch from './watch'
import { init as initBackgroundService } from './BackgroundService'
import { init as initForegroundClient } from './ForegroundClient'
initSourceMapSupport()
initPrettyError()
let initDbPromise: Promise<void> | null = null
let mainWindow: BrowserWindow | null = null
if (!fs.existsSync(config.dotAnsel))
fs.mkdirSync(config.dotAnsel)
app.on('window-all-closed', () => {
// if (process.platform !== 'darwin')
app.quit()
})
app.on('ready', () => {
示例8:
import * as chai from "chai";
import * as chaiAsPromised from "chai-as-promised";
import * as Bluebird from "bluebird";
import * as sourceMapSupport from "source-map-support";
Bluebird.longStackTraces();
sourceMapSupport.install({
handleUncaughtExceptions: false
});
chai.use(chaiAsPromised);
示例9: Koa
"use strict";
import * as sourceMap from "source-map-support";
import * as Koa from "koa";
import { RouterBuilder } from "./Routes/RouterBuilder";
import * as bodyParser from "koa-bodyparser";
import * as Router from "koa-router";
import { activator } from "./DependencyInjection/Activator";
import { generateMiddleware } from "./DependencyInjection/KoaActivatorExtension";
import { A, B } from "./InjectionTest";
import "./Controllers";
sourceMap.install();
const app = new Koa();
const builder = new RouterBuilder();
activator.addSingleton("a1", A)
.addScoped("a2", A)
.addTransient("a3", A)
.addTransient("b", B);
app.use(generateMiddleware(activator));
app.use(bodyParser());
app.use(builder.routes());
app.use(builder.allowedMethods());
app.listen(9001);
示例10:
/// <reference path="../typings/main.d.ts" />
import { install as sourcemapSupport } from 'source-map-support';
import 'mocha';
sourcemapSupport({ handleUncaughtExceptions: false });
export { expect } from 'chai';