Skip to content

Commit

Permalink
Merge pull request #1082 from intuit/updated-title-bug
Browse files Browse the repository at this point in the history
Respect Updated PR Titles
  • Loading branch information
hipstersmoothie authored Mar 27, 2020
2 parents 729fb79 + 7a16473 commit 727fe80
Show file tree
Hide file tree
Showing 109 changed files with 5,846 additions and 5,777 deletions.
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@
"ts-jest": "^25.0.0",
"typescript": "~3.7.2"
},
"prettier": {
"singleQuote": true
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
Expand Down
16 changes: 8 additions & 8 deletions packages/bot-list/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
export default [
'dependabot-preview[bot]',
'greenkeeper[bot]',
'dependabot[bot]',
'fossabot',
'renovate',
'renovate-bot',
'renovate[bot]',
'renovate-approve'
"dependabot-preview[bot]",
"greenkeeper[bot]",
"dependabot[bot]",
"fossabot",
"renovate",
"renovate-bot",
"renovate[bot]",
"renovate-approve",
];
72 changes: 36 additions & 36 deletions packages/cli/__tests__/args.test.ts
Original file line number Diff line number Diff line change
@@ -1,87 +1,87 @@
import parseArgs from '../src/parse-args';
import parseArgs from "../src/parse-args";

const log = jest.fn();
// @ts-ignore
global.console = { log };

describe('root parser', () => {
describe("root parser", () => {
beforeEach(() => {
log.mockClear();
});

test('should print version', () => {
parseArgs('--version'.split(' '));
test("should print version", () => {
parseArgs("--version".split(" "));
expect(log).toHaveBeenCalled();
});

test('should print help', () => {
parseArgs('--help'.split(' '));
test("should print help", () => {
parseArgs("--help".split(" "));
expect(log).toHaveBeenCalled();
});

test('should print help for simple command', () => {
parseArgs('init --help'.split(' '));
test("should print help for simple command", () => {
parseArgs("init --help".split(" "));
expect(log).toHaveBeenCalled();
});

test('should print help for complex command', () => {
parseArgs('pr-status --help'.split(' '));
test("should print help for complex command", () => {
parseArgs("pr-status --help".split(" "));
expect(log).toHaveBeenCalled();
});

test('should exit when required arg is not included', () => {
test("should exit when required arg is not included", () => {
process.exit = jest.fn() as any;
parseArgs(['pr-status']);
parseArgs(["pr-status"]);
expect(process.exit).toHaveBeenCalled();
});

test('should exit when required string is provided as flag', () => {
test("should exit when required string is provided as flag", () => {
process.exit = jest.fn() as any;
parseArgs(['pr-check', '--pr', '24', '--url']);
parseArgs(["pr-check", "--pr", "24", "--url"]);
expect(process.exit).toHaveBeenCalled();
});

test('should parse just provided args', () => {
expect(parseArgs('label --pr 2 --owner adam'.split(' '))).toStrictEqual([
'label',
test("should parse just provided args", () => {
expect(parseArgs("label --pr 2 --owner adam".split(" "))).toStrictEqual([
"label",
expect.objectContaining({
pr: 2,
owner: 'adam'
})
owner: "adam",
}),
]);
});

test('should parse args as camelCase', () => {
expect(parseArgs('changelog -d'.split(' '))).toStrictEqual([
'changelog',
test("should parse args as camelCase", () => {
expect(parseArgs("changelog -d".split(" "))).toStrictEqual([
"changelog",
expect.objectContaining({
dryRun: true
})
dryRun: true,
}),
]);
});

test('error when on in array of options to is not present', () => {
test("error when on in array of options to is not present", () => {
process.exit = jest.fn() as any;
parseArgs(['comment']);
parseArgs(["comment"]);
expect(process.exit).toHaveBeenCalled();
});

test('allow array of options to or', () => {
expect(parseArgs(['comment', '--message', 'foo'])).toStrictEqual([
'comment',
test("allow array of options to or", () => {
expect(parseArgs(["comment", "--message", "foo"])).toStrictEqual([
"comment",
expect.objectContaining({
message: 'foo'
})
message: "foo",
}),
]);
});

test('allow edit in comment', () => {
expect(parseArgs(['comment', '--edit', '--message', 'foo'])).toStrictEqual([
'comment',
test("allow edit in comment", () => {
expect(parseArgs(["comment", "--edit", "--message", "foo"])).toStrictEqual([
"comment",
expect.objectContaining({
edit: true,
message: 'foo'
})
message: "foo",
}),
]);
});
});
12 changes: 6 additions & 6 deletions packages/cli/__tests__/main.test.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import main, { run } from '../src/run';
import main, { run } from "../src/run";

process.env.GH_TOKEN = 'XXXX';
process.env.GH_TOKEN = "XXXX";

test('throws error for unknown args', async () => {
test("throws error for unknown args", async () => {
process.exit = jest.fn() as any;
console.log = jest.fn() as any;

await run('foo', {});
await run("foo", {});

expect(process.exit).toHaveBeenCalledWith(1);
});

test('throws exits for caught error', async () => {
test("throws exits for caught error", async () => {
console.log = jest.fn() as any;
process.exit = jest.fn() as any;

await main('foo', {});
await main("foo", {});

expect(process.exit).toHaveBeenCalledWith(1);
});
28 changes: 14 additions & 14 deletions packages/cli/src/bin/auto.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
#!/usr/bin/env node

import moduleAlias from 'module-alias';
import path from 'path';
import moduleAlias from "module-alias";
import path from "path";

try {
// eslint-disable-next-line
const json = require(path.join(__dirname, '../../package.json'));
const json = require(path.join(__dirname, "../../package.json"));

if (json.name.startsWith('@auto-canary')) {
if (json.name.startsWith("@auto-canary")) {
moduleAlias.addAliases({
'@auto-it': (fromPath: string, request: string) =>
"@auto-it": (fromPath: string, request: string) =>
// We want to rewrite all the imports for canary (ex: npm plugin requiring core)
request.startsWith('@auto-it') &&
request.startsWith("@auto-it") &&
// but we also want to be able to require official plugins from a canary
!fromPath.endsWith('noop.js') &&
!fromPath.endsWith("noop.js") &&
// and don't want to override those plugins's imports
!fromPath.includes('@auto-it')
? '@auto-canary'
: '@auto-it'
!fromPath.includes("@auto-it")
? "@auto-canary"
: "@auto-it",
});
}
} catch (error) {}

import chalk from 'chalk';
import parseArgs from '../parse-args';
import run from '../run';
import chalk from "chalk";
import parseArgs from "../parse-args";
import run from "../run";

const [command, args] = parseArgs();

if (command && args) {
run(command, args).catch((e: Error) => {
console.error(chalk.redBright('Error: '), e.message);
console.error(chalk.redBright("Error: "), e.message);
process.exit(1);
});
}
Loading

0 comments on commit 727fe80

Please sign in to comment.