本文整理汇总了TypeScript中gulp-typescript.reporter.nullReporter方法的典型用法代码示例。如果您正苦于以下问题:TypeScript reporter.nullReporter方法的具体用法?TypeScript reporter.nullReporter怎么用?TypeScript reporter.nullReporter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gulp-typescript.reporter
的用法示例。
在下文中一共展示了reporter.nullReporter方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: error
gulp.task("scripts:ts", () => {
let n_errors = 0
function error(err: {message: string}) {
gutil.log(err.message)
n_errors++
}
const project = ts.createProject(join(paths.src_dir.coffee, "tsconfig.json"))
const compiler = project
.src()
.pipe(sourcemaps.init())
.pipe(project(ts.reporter.nullReporter()).on("error", error))
const result = merge([
compiler.js
.pipe(sourcemaps.write("."))
.pipe(gulp.dest(paths.build_dir.tree)),
compiler.dts
.pipe(gulp.dest(paths.build_dir.types)),
])
result.on("finish", function() {
if (argv.emitError && n_errors > 0) {
gutil.log(`There were ${chalk.red("" + n_errors)} TypeScript errors.`)
process.exit(1)
}
})
return result
})
示例2: require
gulp.task("compiler:ts", () => {
const error = (err: {message: string}) => gutil.log(err.message)
const tsconfig = require(join(paths.src_dir.compiler, "tsconfig.json"))
return gulp.src(join(paths.src_dir.compiler, "compile.ts"))
.pipe(ts(tsconfig.compilerOptions, ts.reporter.nullReporter()).on('error', error))
.pipe(gulp.dest(paths.build_dir.compiler))
})
示例3: error
gulp.task("test:compile", () => {
let n_errors = 0
function error(err: {message: string}) {
gutil.log(err.message)
n_errors++
}
const project = ts.createProject("./test/tsconfig.json")
const compiler = project
.src()
.pipe(project(ts.reporter.nullReporter()).on("error", error))
const result = compiler
.js
.pipe(gulp.dest(join("./build", "test")))
result.on("finish", function() {
if (argv.emitError && n_errors > 0) {
gutil.log(`There were ${chalk.red("" + n_errors)} TypeScript errors.`)
process.exit(1)
}
})
return result
})
示例4: error
gulp.task("scripts:tsjs", ["scripts:coffee", "scripts:js", "scripts:ts"], () => {
function error(err: {message: string}) {
const raw = stripAnsi(err.message)
const result = raw.match(/(.*)(\(\d+,\d+\): error TS(\d+):.*)/)
if (result != null) {
const [, file, rest, code] = result
const real = path.join('src', 'coffee', ...file.split(path.sep).slice(3))
if (fs.existsSync(real)) {
gutil.log(`${chalk.red(real)}${rest}`)
return
}
// XXX: can't enable "6133", because CS generates faulty code for closures
if (["2307", "2688", "6053"].indexOf(code) != -1) {
gutil.log(err.message)
return
}
}
if (!argv.ts)
return
if (typeof argv.ts === "string") {
const keywords = argv.ts.split(",")
for (let keyword of keywords) {
let must = true
if (keyword[0] == "^") {
keyword = keyword.slice(1)
must = false
}
const found = err.message.indexOf(keyword) != -1
if (!((found && must) || (!found && !must)))
return
}
}
gutil.log(err.message)
}
const tree_ts = paths.build_dir.tree_ts
const project = gulp
.src(`${tree_ts}/**/*.ts`)
.pipe(sourcemaps.init())
.pipe(ts(tsconfig.compilerOptions, ts.reporter.nullReporter()).on('error', error))
return merge([
project.js
.pipe(sourcemaps.write("."))
.pipe(gulp.dest(paths.build_dir.tree_js)),
project.dts
.pipe(gulp.dest(paths.build_dir.types)),
])
})
示例5: error
gulp.task("scripts:ts", () => {
const errors: string[] = []
function error(err: {message: string}) {
const text = stripAnsi(err.message)
errors.push(text)
const result = text.match(/(.*)(\(\d+,\d+\): error TS(\d+):.*)/)
if (result != null) {
const [, file, , code] = result
if (is_partial(file)) {
if (is_excluded(parseInt(code))) {
if (!(argv.include && text.includes(argv.include)))
return
}
}
}
if (argv.filter && !text.includes(argv.filter))
return
gutil.log(err.message)
}
const tsconfig = require(join(paths.src_dir.coffee, "tsconfig.json"))
let compilerOptions = tsconfig.compilerOptions
if (argv.es6) {
compilerOptions.target = "ES6"
compilerOptions.lib[0] = "es6"
}
const project = gulp
.src(join(paths.src_dir.coffee, "**", "*.ts"))
.pipe(sourcemaps.init())
.pipe(ts(tsconfig.compilerOptions, ts.reporter.nullReporter()).on('error', error))
const result = merge([
project.js
.pipe(sourcemaps.write("."))
.pipe(gulp.dest(paths.build_dir.tree)),
project.dts
.pipe(gulp.dest(paths.build_dir.types)),
])
result.on("finish", () => {
fs.writeFileSync(join(paths.build_dir.js, "ts.log"), errors.join("\n"))
})
return result
})
示例6: require
import * as fs from "fs"
import {join} from "path"
import * as gulp from "gulp"
import * as gutil from "gulp-util"
import * as ts from 'gulp-typescript'
import * as run from 'run-sequence'
import {argv} from "yargs"
const BASE_DIR = "./examples"
const reporter = ts.reporter.nullReporter()
const compile = (name: string) => {
const project = ts.createProject(join(BASE_DIR, name, "tsconfig.json"), {
typescript: require('typescript')
})
return project.src()
.pipe(project(reporter).on('error', (err: {message: string}) => gutil.log(err.message)))
.pipe(gulp.dest(join(BASE_DIR, name)))
}
const examples: string[] = []
for(const name of fs.readdirSync("./examples")) {
const stats = fs.statSync(join(BASE_DIR, name))
if (stats.isDirectory() && fs.existsSync(join(BASE_DIR, name, "tsconfig.json"))) {
examples.push(name)
gulp.task(`examples:${name}`, () => compile(name))
}
}