本文整理汇总了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)
}
})
示例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
}
})
示例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
示例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`.'
)
}
示例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.")
}
示例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.'
)
}
示例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
示例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}.`)
}
示例9: fail
tsLintResult.forEach(tsLintFail => {
fail(`${tsLintFail}`);
});