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

TypeScript danger.warn函数代码示例

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

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



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

示例1: async

// tslint:disable-next-line:no-default-export
export default async () => {
  // Warn about creating new JS files
  const jsFiles = danger.git.created_files.filter(
    f => f.includes("src") && f.endsWith(".js")
  )
  if (jsFiles.length) {
    const files = danger.github.utils.fileLinks(jsFiles)
    warn(
      `Please don't include .js files, we want to be using TypeScript found: ${files}.`
    )
  }

  const isReleasePR = danger.github.pr.base.ref === "release"
  const versionToCheck = isReleasePR ? "production" : "staging"
  const changes: string[] = await getBreakingChanges(versionToCheck)

  // There are breaking changes with the schema
  if (changes.length) {
    if (isReleasePR) {
      const deployURL = "https://github.com/artsy/metaphysics#deployment"
      fail(
        `You need to promote Metaphysics from staging to production. The schema used in Reaction, is further ahead than the version in Metaphyisc production. This could cause your queries to fail. You can see how to [deploy here](${deployURL}).`
      )
    } else {
      warn(
        "The staging version of Metaphysics has breaking changes, this might not affect your build, but could mean your queries don't work the way you expect. See below for breaking changes:"
      )
    }

    // Show a list of the changes
    markdown(changes.map(change => `- :warning: ${change}`).join("\n"))
  }
}
开发者ID:artsy,项目名称:force-public,代码行数:34,代码来源:dangerfile.ts


示例2: 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


示例3: async

export default async () => {
  if (!danger.github) {
    return;
  }

  schedule(async () => {
    const tsLintResult = (await Promise.all(
      packages.map(packageName => {
        return new Promise<string>(res => {
          tslint({
            lintResultsJsonPath: resolve(__dirname, 'packages', packageName, 'lint-results.json'),
            handleResults: results => {
              if (results.length > 0) {
                const formattedResults = prettyResults(results);
                res(`TSLint failed: **@sentry/${packageName}**\n\n${formattedResults}`);
              } else {
                res('');
              }
            },
          });
        });
      }),
    )).filter(str => str.length);
    if (tsLintResult.length) {
      tsLintResult.forEach(tsLintFail => {
        fail(`${tsLintFail}`);
      });
    } else {
      message('✅ TSLint passed');
    }
  });

  const hasChangelog = danger.git.modified_files.indexOf('CHANGELOG.md') !== -1;
  const isTrivial = (danger.github.pr.body + danger.github.pr.title).includes('#trivial');

  if (!hasChangelog && !isTrivial) {
    warn('Please add a changelog entry for your changes.');
  }

  schedule(async () => {
    const result = (await promisify(exec)('cd packages/browser; yarn size:check')).stdout;
    message(`@sentry/browser bundle gzip'ed minified size: *(${result.split('\n')[3]}) (${result.split('\n')[4]})*`);
  });
};
开发者ID:getsentry,项目名称:raven-js,代码行数:44,代码来源:dangerfile.ts


示例4: includes

const modifiedAppFiles = modified.filter(p => includes(p, "lib/")).filter(p => filesOnly(p) && typescriptOnly(p))

// Modified or Created can be treated the same a lot of the time
const touchedFiles = modified.concat(danger.git.created_files).filter(p => filesOnly(p))

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

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
开发者ID:artsy,项目名称:emission,代码行数:31,代码来源:dangerfile.ts


示例5: require

import { danger, warn, fail, message } from 'danger'
import { CLIEngine } from 'eslint'
import { readFileSync } from 'fs'
import { insert } from 'markdown-toc'
import { getFileInfo, resolveConfig, check, format } from 'prettier'
import minimatch = require('minimatch')

/* eslint no-undef: off */
/* REASON: not compatible with import = require() syntax. */

// No PR is too small to include a description of why you made a change
if (danger.github) {
  if (danger.github.pr.body.length < 10) {
    warn('Please include a description of your PR changes.')
  }
}

const filesToCheck = danger.git.created_files.concat(danger.git.modified_files)

// ESLint
const cli = new CLIEngine({})
const eslintPattern = '*.{js,jsx,ts,tsx}'
const filesToLint = filesToCheck
  .filter(path => minimatch(path, eslintPattern, { matchBase: true }))
  .filter(path => !cli.isPathIgnored(path))
const report = cli.executeOnFiles(filesToLint)
report.results.forEach(result => {
  const { filePath } = result
  result.messages.forEach(msg => {
    const { line, message, ruleId } = msg
    const rule = ruleId || 'N/A'
开发者ID:bemusic,项目名称:bemuse,代码行数:31,代码来源:dangerfile.ts


示例6: warn

  }

  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
  const bigPRThreshold = 500;
  if (
    danger.github.pr.additions + danger.github.pr.deletions >
    bigPRThreshold
  ) {
    warn(':exclamation: Big PR');
  }

  // Warn if there are library changes, but not tests
  if (hasAppChanges && !hasTestChanges) {
    warn(
      "There are library changes, but not tests. That's OK as long as you're refactoring existing code",
    );
  }

  // Be careful of leaving testing shortcuts in the codebase
  const onlyTestFiles = testChanges.filter(x => {
    const content = fs.readFileSync(x).toString();
    return (
      content.includes('it.only') ||
      content.includes('describe.only') ||
开发者ID:hammadj,项目名称:apollo-client,代码行数:31,代码来源:dangerfile.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript full-defence-transitions.fullDefenceTransitions函数代码示例发布时间:2022-05-25
下一篇:
TypeScript danger.fail函数代码示例发布时间: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