當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript gulp-typescript.reporter類代碼示例

本文整理匯總了TypeScript中gulp-typescript.reporter的典型用法代碼示例。如果您正苦於以下問題:TypeScript reporter類的具體用法?TypeScript reporter怎麽用?TypeScript reporter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了reporter類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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
})
開發者ID:Zyell,項目名稱:bokeh,代碼行數:31,代碼來源:scripts.ts

示例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))
})
開發者ID:alamont,項目名稱:bokeh,代碼行數:7,代碼來源:compiler.ts

示例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
})
開發者ID:Zyell,項目名稱:bokeh,代碼行數:26,代碼來源:test.ts

示例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)),
  ])
})
開發者ID:jsalcal,項目名稱:bokeh,代碼行數:54,代碼來源:scripts.ts

示例5: compile

export function compile({
  declarations = false,
  tsProjectOptions = {},
  tsProject,
  compilePaths = getCompilePaths(),
  outputDir = '.',
  definitionsDir = 'definitions',
  reporter = tsReporter.fullReporter(true)
}: {
  declarations?: boolean;
  tsProjectOptions?: any;
  tsProject?: any,
  compilePaths?: Array<string>;
  outputDir?: string;
  definitionsDir?: string;
  reporter?: any;
}) {
  log('------------------------------------------');
  log('===> Starting typescript compilation...');
  log('------------------------------------------');
  const startTime = new Date();
  const tsProjectToUse = tsProject || createTsProjectFromOptions({
      tsProjectOptions,
      declarations
    });

  const tsResult = src(compilePaths, {base: "."})
    .pipe(sourcemaps.init())
    .pipe(tsProjectToUse(reporter) as any);

  const jsFiles = tsResult.js
    .pipe(sourcemaps.write())
    .pipe(dest(outputDir))
    .on('error', (err) => {
      log('------------------------------------------');
      log('<=== Failed to compile sources. ' + err.stack);
      log('------------------------------------------');
    })
    .on('end', () => {
      const compilationTime = Math.round((new Date().getTime() - startTime.getTime()) / 1000 * 100) / 100;

      log('------------------------------------------');
      log(`<=== Typescript source compiling finished in ${compilationTime} sec.`);
      log('------------------------------------------');
    });

  const dtsFiles = tsResult.dts.pipe(
    dest(join(outputDir, definitionsDir))
  );

  return merge([jsFiles, dtsFiles]) as any;
}
開發者ID:netanelgilad,項目名稱:bigg-typescript,代碼行數:52,代碼來源:compile.ts

示例6: 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
})
開發者ID:FourtekIT-incubator,項目名稱:bokeh,代碼行數:49,代碼來源:scripts.ts

示例7: 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))
  }
}
開發者ID:FourtekIT-incubator,項目名稱:bokeh,代碼行數:30,代碼來源:examples.ts


注:本文中的gulp-typescript.reporter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。