• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript danger.fail函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中danger.fail函数的典型用法代码示例。如果您正苦于以下问题:TypeScript fail函数的具体用法?TypeScript fail怎么用?TypeScript fail使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了fail函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: warn

 result.messages.forEach(msg => {
   const { line, message, ruleId } = msg
   const rule = ruleId || 'N/A'
   const messageText = `${filePath} line ${line} – ${message} (${rule})`
   if (msg.severity === 1) {
     warn(messageText)
   } else if (msg.severity === 2) {
     fail(messageText)
   }
 })
开发者ID:bemusic,项目名称:bemuse,代码行数:10,代码来源:dangerfile.ts


示例2: minimatch

filesToCheck.forEach(filePath => {
  const matchesPattern = minimatch(filePath, prettierPattern, {
    matchBase: true,
  })
  if (!matchesPattern) return
  const fileInfo = getFileInfo.sync(filePath)
  if (fileInfo.ignored) return
  if (!fileInfo.inferredParser) return
  const source = readFileSync(filePath, 'utf8')
  const config = resolveConfig.sync(filePath)
  const options = { ...config, parser: fileInfo.inferredParser }
  if (!check(source, options)) {
    fail(`${filePath} is not formatted using Prettier.`)
    prettierFailed = true
  }
})
开发者ID:bemusic,项目名称:bemuse,代码行数:16,代码来源:dangerfile.ts


示例3: includes

)

const touchedComponents = touchedFiles.filter(p => includes(p, "src/lib/components") && !includes(p, "__tests__"))

// Rules

// If it's not a branch PR
if (pr.base.repo.full_name !== pr.head.repo.full_name) {
  warn("This PR comes from a fork, and won't get JS generated for QA testing this PR inside the Emission Example app.")
}

// When there are app-changes and it's not a PR marked as trivial, expect
// there to be CHANGELOG changes.
const changelogChanges = includes(modified, "CHANGELOG.md")
if (modifiedAppFiles.length > 0 && !trivialPR && !changelogChanges) {
  fail("No CHANGELOG added.")
}

// Check that the changelog contains only H3's
if (changelogChanges && fs.readFileSync("CHANGELOG.md", "utf8").includes("\n## ")) {
  fail("Changelog must only contain H3's, but contains H2's.")
}

// Check that every file touched has a corresponding test file
const correspondingTestsForAppFiles = touchedAppOnlyFiles.map(f => {
  const newPath = path.dirname(f)
  const name = path.basename(f).replace(".ts", "-tests.ts")
  return `${newPath}/__tests__/${name}`
})

// New app files should get new test files
开发者ID:artsy,项目名称:emission,代码行数:31,代码来源:dangerfile.ts


示例4: readFileSync

    matchBase: true,
  })
  if (!matchesPattern) return
  const fileInfo = getFileInfo.sync(filePath)
  if (fileInfo.ignored) return
  if (!fileInfo.inferredParser) return
  const source = readFileSync(filePath, 'utf8')
  const config = resolveConfig.sync(filePath)
  const options = { ...config, parser: fileInfo.inferredParser }
  if (!check(source, options)) {
    fail(`${filePath} is not formatted using Prettier.`)
    prettierFailed = true
  }
})
if (prettierFailed) {
  message(
    'You can run `yarn style:fix` to automatically format all files using Prettier.'
  )
}

// Readme
const readme = readFileSync('README.md', 'utf8')
const formattedReadme = format(insert(readme), {
  parser: 'markdown',
})
if (formattedReadme !== readme) {
  fail(
    'Please format the README and update its table of contents using `yarn readme:update`.'
  )
}
开发者ID:bemusic,项目名称:bemuse,代码行数:30,代码来源:dangerfile.ts


示例5: require

const { danger, fail } = require('danger')

const someoneAssigned = danger.github.pr.assignee
if (someoneAssigned === null) {
  fail("Please assign someone to merge this PR, and optionally include people who should review.")
}
if (danger.github.pr.body.length === 0) {
  fail("Please describe your PR.")
}
开发者ID:artsy,项目名称:positron,代码行数:9,代码来源:dangerfile.ts


示例6: filesOnly

import { danger, fail } from 'danger'
import * as fs from 'fs'

const pr = danger.github.pr
const modified = danger.git.modified_files
const bodyAndTitle = (pr.body + pr.title).toLowerCase()
const trivialPR = bodyAndTitle.includes('#trivial')

const typescriptOnly = (file: string) => file.includes('.ts')
const filesOnly = (file: string) => fs.existsSync(file) && fs.lstatSync(file).isFile()

// Custom subsets of known files
const modifiedAppFiles = modified.filter(p => p.includes('src/')).filter(p => filesOnly(p) && typescriptOnly(p))

// Rules

// When there are app-changes and it's not a PR marked as trivial, expect
// there to be CHANGELOG changes.
const changelogChanges = modified.includes('CHANGELOG.md')
if (modifiedAppFiles.length > 0 && !trivialPR && !changelogChanges) {
  fail(
    '**No CHANGELOG added.** If this is a small PR, or a bug-fix for an unreleased bug add `#trivial` to your PR message and re-run CI.'
  )
}
开发者ID:bookman25,项目名称:vscode-jest,代码行数:24,代码来源:dangerfile.ts


示例7: includes

// Rules
if (!isBot) {
  // make sure someone else reviews these changes
  // const someoneAssigned = danger.github.pr.assignee;
  // if (someoneAssigned === null) {
  //   warn(
  //     'Please assign someone to merge this PR, and optionally include people who should review.'
  //   );
  // }

  // When there are app-changes and it's not a PR marked as trivial, expect
  // there to be CHANGELOG changes.
  const changelogChanges = includes(modified, 'CHANGELOG.md');
  if (modifiedAppFiles.length > 0 && !trivialPR && !changelogChanges) {
    fail('No CHANGELOG added.');
  }

  // No PR is too small to warrant a paragraph or two of summary
  if (pr.body.length === 0) {
    fail('Please add a description to your PR.');
  }

  const hasAppChanges = modifiedAppFiles.length > 0;

  const testChanges = modifiedAppFiles.filter(filepath =>
    filepath.includes('test'),
  );
  const hasTestChanges = testChanges.length > 0;

  // Warn when there is a big PR
开发者ID:hammadj,项目名称:apollo-client,代码行数:30,代码来源:dangerfile.ts


示例8: fail

import { danger, fail } from "danger"

// Rule: encourage all new files to be TypeScript
const jsAppFiles = danger.git.created_files.filter(
  f => f.startsWith("src/") && f.endsWith(".js")
)

if (jsAppFiles.length) {
  const listed = danger.github.utils.fileLinks(jsAppFiles)
  fail(`Please use <code>*.ts</code> for new files. Found: ${listed}.`)
}
开发者ID:xtina-starr,项目名称:metaphysics,代码行数:11,代码来源:dangerfile.ts


示例9: fail

 tsLintResult.forEach(tsLintFail => {
   fail(`${tsLintFail}`);
 });
开发者ID:getsentry,项目名称:raven-js,代码行数:3,代码来源:dangerfile.ts



注:本文中的danger.fail函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript danger.warn函数代码示例发布时间:2022-05-25
下一篇:
TypeScript dagre.layout函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap