Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: upgrade execa to 3.4.0 #984

Merged
merged 3 commits into from
Feb 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion @commitlint/cli/package.json
Expand Up @@ -53,7 +53,7 @@
"@commitlint/utils": "^8.3.4",
"babel-preset-commitlint": "^8.2.0",
"cross-env": "7.0.0",
"execa": "0.11.0",
"execa": "^3.4.0",
"fs-extra": "^8.1.0"
},
"dependencies": {
Expand Down
68 changes: 34 additions & 34 deletions @commitlint/cli/src/cli.test.js
Expand Up @@ -8,12 +8,12 @@ const bin = require.resolve('../lib/cli.js');

const cli = (args, options) => {
return (input = '') => {
const c = execa(bin, args, {
return execa(bin, args, {
cwd: options.cwd,
env: options.env,
input: input
input: input,
reject: false
});
return c.catch(err => err);
};
};

Expand All @@ -23,7 +23,7 @@ const fixBootstrap = fixture => fix.bootstrap(fixture, __dirname);
test('should throw when called without [input]', async () => {
const cwd = await gitBootstrap('fixtures/default');
const actual = await cli([], {cwd})();
expect(actual.code).toBe(1);
expect(actual.exitCode).toBe(1);
});

test('should reprint input from stdin', async () => {
Expand Down Expand Up @@ -57,7 +57,7 @@ test('should produce help for empty config', async () => {
const cwd = await gitBootstrap('fixtures/empty');
const actual = await cli([], {cwd})('foo: bar');
expect(actual.stdout).toContain('Please add rules');
expect(actual.code).toBe(1);
expect(actual.exitCode).toBe(1);
});

test('should produce help for problems', async () => {
Expand All @@ -66,7 +66,7 @@ test('should produce help for problems', async () => {
expect(actual.stdout).toContain(
'Get help: https://github.com/conventional-changelog/commitlint/#what-is-commitlint'
);
expect(actual.code).toBe(1);
expect(actual.exitCode).toBe(1);
});

test('should produce help for problems with correct helpurl', async () => {
Expand All @@ -78,57 +78,57 @@ test('should produce help for problems with correct helpurl', async () => {
expect(actual.stdout).toContain(
'Get help: https://github.com/conventional-changelog/commitlint/#testhelpurl'
);
expect(actual.code).toBe(1);
expect(actual.exitCode).toBe(1);
});

test('should fail for input from stdin without rules', async () => {
const cwd = await gitBootstrap('fixtures/empty');
const actual = await cli([], {cwd})('foo: bar');
expect(actual.code).toBe(1);
expect(actual.exitCode).toBe(1);
});

test('should succeed for input from stdin with rules', async () => {
const cwd = await gitBootstrap('fixtures/default');
const actual = await cli([], {cwd})('type: bar');
expect(actual.code).toBe(0);
expect(actual.exitCode).toBe(0);
});

test('should fail for input from stdin with rule from rc', async () => {
const cwd = await gitBootstrap('fixtures/simple');
const actual = await cli([], {cwd})('foo: bar');
expect(actual.stdout).toContain('type must not be one of [foo]');
expect(actual.code).toBe(1);
expect(actual.exitCode).toBe(1);
});

test('should work with --config option', async () => {
const file = 'config/commitlint.config.js';
const cwd = await gitBootstrap('fixtures/specify-config-file');
const actual = await cli(['--config', file], {cwd})('foo: bar');
expect(actual.stdout).toContain('type must not be one of [foo]');
expect(actual.code).toBe(1);
expect(actual.exitCode).toBe(1);
});

test('should fail for input from stdin with rule from js', async () => {
const cwd = await gitBootstrap('fixtures/extends-root');
const actual = await cli(['--extends', './extended'], {cwd})('foo: bar');
expect(actual.stdout).toContain('type must not be one of [foo]');
expect(actual.code).toBe(1);
expect(actual.exitCode).toBe(1);
});

test('should produce no error output with --quiet flag', async () => {
const cwd = await gitBootstrap('fixtures/simple');
const actual = await cli(['--quiet'], {cwd})('foo: bar');
expect(actual.stdout).toEqual('');
expect(actual.stderr).toEqual('');
expect(actual.code).toBe(1);
expect(actual.exitCode).toBe(1);
});

test('should produce no error output with -q flag', async () => {
const cwd = await gitBootstrap('fixtures/simple');
const actual = await cli(['-q'], {cwd})('foo: bar');
expect(actual.stdout).toEqual('');
expect(actual.stderr).toEqual('');
expect(actual.code).toBe(1);
expect(actual.exitCode).toBe(1);
});

test('should work with husky commitmsg hook and git commit', async () => {
Expand Down Expand Up @@ -236,7 +236,7 @@ test('should allow reading of environment variables for edit file, succeeding if
cwd,
env: {variable: 'commit-msg-file'}
})();
expect(actual.code).toBe(0);
expect(actual.exitCode).toBe(0);
});

test('should allow reading of environment variables for edit file, failing if invalid', async () => {
Expand All @@ -249,15 +249,15 @@ test('should allow reading of environment variables for edit file, failing if in
cwd,
env: {variable: 'commit-msg-file'}
})();
expect(actual.code).toBe(1);
expect(actual.exitCode).toBe(1);
});

test('should pick up parser preset and fail accordingly', async () => {
const cwd = await gitBootstrap('fixtures/parser-preset');
const actual = await cli(['--parser-preset', './parser-preset'], {cwd})(
'type(scope): subject'
);
expect(actual.code).toBe(1);
expect(actual.exitCode).toBe(1);
expect(actual.stdout).toContain('may not be empty');
});

Expand All @@ -266,39 +266,39 @@ test('should pick up parser preset and succeed accordingly', async () => {
const actual = await cli(['--parser-preset', './parser-preset'], {cwd})(
'----type(scope): subject'
);
expect(actual.code).toBe(0);
expect(actual.exitCode).toBe(0);
});

test('should pick up config from outside git repo and fail accordingly', async () => {
const outer = await fixBootstrap('fixtures/outer-scope');
const cwd = await git.init(path.join(outer, 'inner-scope'));

const actual = await cli([], {cwd})('inner: bar');
expect(actual.code).toBe(1);
expect(actual.exitCode).toBe(1);
});

test('should pick up config from outside git repo and succeed accordingly', async () => {
const outer = await fixBootstrap('fixtures/outer-scope');
const cwd = await git.init(path.join(outer, 'inner-scope'));

const actual = await cli([], {cwd})('outer: bar');
expect(actual.code).toBe(0);
expect(actual.exitCode).toBe(0);
});

test('should pick up config from inside git repo with precedence and succeed accordingly', async () => {
const outer = await fixBootstrap('fixtures/inner-scope');
const cwd = await git.init(path.join(outer, 'inner-scope'));

const actual = await cli([], {cwd})('inner: bar');
expect(actual.code).toBe(0);
expect(actual.exitCode).toBe(0);
});

test('should pick up config from inside git repo with precedence and fail accordingly', async () => {
const outer = await fixBootstrap('fixtures/inner-scope');
const cwd = await git.init(path.join(outer, 'inner-scope'));

const actual = await cli([], {cwd})('outer: bar');
expect(actual.code).toBe(1);
expect(actual.exitCode).toBe(1);
});

test('should handle --amend with signoff', async () => {
Expand All @@ -320,7 +320,7 @@ test('should handle --amend with signoff', async () => {
test('should handle linting with issue prefixes', async () => {
const cwd = await gitBootstrap('fixtures/issue-prefixes');
const actual = await cli([], {cwd})('foobar REF-1');
expect(actual.code).toBe(0);
expect(actual.exitCode).toBe(0);
}, 10000);

test('should print full commit message when input from stdin fails', async () => {
Expand All @@ -330,7 +330,7 @@ test('should print full commit message when input from stdin fails', async () =>
const actual = await cli(['--color=false'], {cwd})(input);

expect(actual.stdout).toContain(input);
expect(actual.code).toBe(1);
expect(actual.exitCode).toBe(1);
});

test('should not print commit message fully or partially when input succeeds', async () => {
Expand All @@ -341,7 +341,7 @@ test('should not print commit message fully or partially when input succeeds', a

expect(actual.stdout).not.toContain(message);
expect(actual.stdout).not.toContain(message.split('\n')[0]);
expect(actual.code).toBe(0);
expect(actual.exitCode).toBe(0);
});

test('should fail for invalid formatters from configuration', async () => {
Expand All @@ -352,37 +352,37 @@ test('should fail for invalid formatters from configuration', async () => {
'Using format custom-formatter, but cannot find the module'
);
expect(actual.stdout).toEqual('');
expect(actual.code).toBe(1);
expect(actual.exitCode).toBe(1);
});

test('should skip linting if message matches ignores config', async () => {
const cwd = await gitBootstrap('fixtures/ignores');
const actual = await cli([], {cwd})('WIP');
expect(actual.code).toBe(0);
expect(actual.exitCode).toBe(0);
});

test('should not skip linting if message does not match ignores config', async () => {
const cwd = await gitBootstrap('fixtures/ignores');
const actual = await cli([], {cwd})('foo');
expect(actual.code).toBe(1);
expect(actual.exitCode).toBe(1);
});

test('should not skip linting if defaultIgnores is false', async () => {
const cwd = await gitBootstrap('fixtures/default-ignores-false');
const actual = await cli([], {cwd})('fixup! foo: bar');
expect(actual.code).toBe(1);
expect(actual.exitCode).toBe(1);
});

test('should skip linting if defaultIgnores is true', async () => {
const cwd = await gitBootstrap('fixtures/default-ignores-true');
const actual = await cli([], {cwd})('fixup! foo: bar');
expect(actual.code).toBe(0);
expect(actual.exitCode).toBe(0);
});

test('should skip linting if defaultIgnores is unset', async () => {
const cwd = await gitBootstrap('fixtures/default-ignores-unset');
const actual = await cli([], {cwd})('fixup! foo: bar');
expect(actual.code).toBe(0);
expect(actual.exitCode).toBe(0);
});

test('should fail for invalid formatters from flags', async () => {
Expand All @@ -393,7 +393,7 @@ test('should fail for invalid formatters from flags', async () => {
'Using format through-flag, but cannot find the module'
);
expect(actual.stdout).toEqual('');
expect(actual.code).toBe(1);
expect(actual.exitCode).toBe(1);
});

test('should work with absolute formatter path', async () => {
Expand All @@ -407,7 +407,7 @@ test('should work with absolute formatter path', async () => {
);

expect(actual.stdout).toContain('custom-formatter-ok');
expect(actual.code).toBe(0);
expect(actual.exitCode).toBe(0);
});

test('should work with relative formatter path', async () => {
Expand All @@ -420,7 +420,7 @@ test('should work with relative formatter path', async () => {
);

expect(actual.stdout).toContain('custom-formatter-ok');
expect(actual.code).toBe(0);
expect(actual.exitCode).toBe(0);
});

async function writePkg(payload, options) {
Expand Down
2 changes: 1 addition & 1 deletion @commitlint/load/package.json
Expand Up @@ -37,7 +37,7 @@
"@commitlint/test": "8.2.0",
"@commitlint/utils": "^8.3.4",
"@types/lodash": "4.14.149",
"execa": "0.11.0"
"execa": "^3.4.0"
},
"dependencies": {
"@commitlint/execute-rule": "^8.3.4",
Expand Down
6 changes: 3 additions & 3 deletions @commitlint/prompt-cli/cli.test.js
Expand Up @@ -5,12 +5,12 @@ const bin = require.resolve('./cli.js');

const cli = (args, options) => {
return (input = '') => {
const c = execa(bin, args, {
return execa(bin, args, {
cwd: options.cwd,
env: options.env,
input: input
input: input,
reject: false
});
return c.catch(err => err);
};
};

Expand Down
2 changes: 1 addition & 1 deletion @commitlint/prompt-cli/package.json
Expand Up @@ -36,6 +36,6 @@
},
"dependencies": {
"@commitlint/prompt": "^8.3.5",
"execa": "0.11.0"
"execa": "^3.4.0"
}
}
2 changes: 1 addition & 1 deletion @commitlint/travis-cli/package.json
Expand Up @@ -54,6 +54,6 @@
},
"dependencies": {
"@commitlint/cli": "^8.3.5",
"execa": "0.11.0"
"execa": "^3.4.0"
}
}
3 changes: 1 addition & 2 deletions @packages/test/package.json
Expand Up @@ -29,10 +29,9 @@
},
"license": "MIT",
"dependencies": {
"@types/execa": "^0.9.0",
"@types/fs-extra": "^8.0.1",
"@types/tmp": "^0.1.0",
"execa": "0.11.0",
"execa": "^3.4.0",
"fs-extra": "^8.1.0",
"pkg-dir": "4.2.0",
"resolve-pkg": "2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion @packages/utils/dep-check.js
Expand Up @@ -23,7 +23,7 @@ main().then(args => {
console.log(`Checking dependencies ${path.join(cwd, 'package.json')}`);
if (err) {
console.error(err.stderr);
process.exit(err.code);
process.exit(err.exitCode);
}
if (out) {
console.log(out);
Expand Down
2 changes: 1 addition & 1 deletion @packages/utils/package.json
Expand Up @@ -37,7 +37,7 @@
"license": "MIT",
"dependencies": {
"@commitlint/test": "8.2.0",
"execa": "0.11.0",
"execa": "^3.4.0",
"is-builtin-module": "3.0.0",
"meow": "4.0.1",
"read-pkg": "5.2.0",
Expand Down