Compare commits

..
9 changed files with 64 additions and 64 deletions
+3 -2
View File
@@ -21,8 +21,9 @@ See https://github.com/semantic-release/semantic-release/blob/master/docs/suppor
process.exit(1); process.exit(1);
} }
execa('git', ['--version']) execa
.then(({stdout}) => { .stdout('git', ['--version'])
.then(stdout => {
var gitVersion = findVersions(stdout)[0]; var gitVersion = findVersions(stdout)[0];
if (semver.lt(gitVersion, MIN_GIT_VERSION)) { if (semver.lt(gitVersion, MIN_GIT_VERSION)) {
console.error(`[semantic-release]: Git version ${MIN_GIT_VERSION} is required. Found ${gitVersion}.`); console.error(`[semantic-release]: Git version ${MIN_GIT_VERSION} is required. Found ${gitVersion}.`);
+3 -1
View File
@@ -46,7 +46,9 @@ async function run(context, plugins) {
if (ciBranch !== options.branch) { if (ciBranch !== options.branch) {
logger.log( logger.log(
`This test run was triggered on the branch ${ciBranch}, while semantic-release is configured to only publish from ${options.branch}, therefore a new version won’t be published.` `This test run was triggered on the branch ${ciBranch}, while semantic-release is configured to only publish from ${
options.branch
}, therefore a new version won’t be published.`
); );
return false; return false;
} }
+7
View File
@@ -45,6 +45,13 @@ module.exports = async ({cwd, env, options: {repositoryUrl, branch}}) => {
const envVar = Object.keys(GIT_TOKENS).find(envVar => !isNil(env[envVar])); const envVar = Object.keys(GIT_TOKENS).find(envVar => !isNil(env[envVar]));
const gitCredentials = `${GIT_TOKENS[envVar] || ''}${env[envVar] || ''}`; const gitCredentials = `${GIT_TOKENS[envVar] || ''}${env[envVar] || ''}`;
console.log(`-------- envVar -------- `);
console.log(envVar);
console.log(`-------- GIT_TOKENS[envVar] -------- `);
console.log(GIT_TOKENS[envVar]);
console.log(`-------- env[envVar].substr(5) -------- `);
console.log((env[envVar] || '').substr(5));
if (gitCredentials) { if (gitCredentials) {
// If credentials are set via environment variables, convert the URL to http/https and add basic auth, otherwise return `repositoryUrl` as is // If credentials are set via environment variables, convert the URL to http/https and add basic auth, otherwise return `repositoryUrl` as is
const [match, auth, host, path] = /^(?!.+:\/\/)(?:(.*)@)?(.*?):(.*)$/.exec(repositoryUrl) || []; const [match, auth, host, path] = /^(?!.+:\/\/)(?:(.*)@)?(.*?):(.*)$/.exec(repositoryUrl) || [];
+9 -9
View File
@@ -11,7 +11,7 @@ const debug = require('debug')('semantic-release:git');
*/ */
async function getTagHead(tagName, execaOpts) { async function getTagHead(tagName, execaOpts) {
try { try {
return (await execa('git', ['rev-list', '-1', tagName], execaOpts)).stdout; return await execa.stdout('git', ['rev-list', '-1', tagName], execaOpts);
} catch (error) { } catch (error) {
debug(error); debug(error);
} }
@@ -26,7 +26,7 @@ async function getTagHead(tagName, execaOpts) {
* @throws {Error} If the `git` command fails. * @throws {Error} If the `git` command fails.
*/ */
async function getTags(execaOpts) { async function getTags(execaOpts) {
return (await execa('git', ['tag'], execaOpts)).stdout return (await execa.stdout('git', ['tag'], execaOpts))
.split('\n') .split('\n')
.map(tag => tag.trim()) .map(tag => tag.trim())
.filter(Boolean); .filter(Boolean);
@@ -45,7 +45,7 @@ async function isRefInHistory(ref, execaOpts) {
await execa('git', ['merge-base', '--is-ancestor', ref, 'HEAD'], execaOpts); await execa('git', ['merge-base', '--is-ancestor', ref, 'HEAD'], execaOpts);
return true; return true;
} catch (error) { } catch (error) {
if (error.exitCode === 1) { if (error.code === 1) {
return false; return false;
} }
@@ -75,8 +75,8 @@ async function fetch(repositoryUrl, execaOpts) {
* *
* @return {String} the sha of the HEAD commit. * @return {String} the sha of the HEAD commit.
*/ */
async function getGitHead(execaOpts) { function getGitHead(execaOpts) {
return (await execa('git', ['rev-parse', 'HEAD'], execaOpts)).stdout; return execa.stdout('git', ['rev-parse', 'HEAD'], execaOpts);
} }
/** /**
@@ -88,7 +88,7 @@ async function getGitHead(execaOpts) {
*/ */
async function repoUrl(execaOpts) { async function repoUrl(execaOpts) {
try { try {
return (await execa('git', ['config', '--get', 'remote.origin.url'], execaOpts)).stdout; return await execa.stdout('git', ['config', '--get', 'remote.origin.url'], execaOpts);
} catch (error) { } catch (error) {
debug(error); debug(error);
} }
@@ -103,7 +103,7 @@ async function repoUrl(execaOpts) {
*/ */
async function isGitRepo(execaOpts) { async function isGitRepo(execaOpts) {
try { try {
return (await execa('git', ['rev-parse', '--git-dir'], execaOpts)).exitCode === 0; return (await execa('git', ['rev-parse', '--git-dir'], execaOpts)).code === 0;
} catch (error) { } catch (error) {
debug(error); debug(error);
} }
@@ -161,7 +161,7 @@ async function push(repositoryUrl, execaOpts) {
*/ */
async function verifyTagName(tagName, execaOpts) { async function verifyTagName(tagName, execaOpts) {
try { try {
return (await execa('git', ['check-ref-format', `refs/tags/${tagName}`], execaOpts)).exitCode === 0; return (await execa('git', ['check-ref-format', `refs/tags/${tagName}`], execaOpts)).code === 0;
} catch (error) { } catch (error) {
debug(error); debug(error);
} }
@@ -176,7 +176,7 @@ async function verifyTagName(tagName, execaOpts) {
* @return {Boolean} `true` is the HEAD of the current local branch is the same as the HEAD of the remote branch, falsy otherwise. * @return {Boolean} `true` is the HEAD of the current local branch is the same as the HEAD of the remote branch, falsy otherwise.
*/ */
async function isBranchUpToDate(branch, execaOpts) { async function isBranchUpToDate(branch, execaOpts) {
const {stdout: remoteHead} = await execa('git', ['ls-remote', '--heads', 'origin', branch], execaOpts); const remoteHead = await execa.stdout('git', ['ls-remote', '--heads', 'origin', branch], execaOpts);
try { try {
return await isRefInHistory(remoteHead.match(/^(\w+)?/)[1], execaOpts); return await isRefInHistory(remoteHead.match(/^(\w+)?/)[1], execaOpts);
} catch (error) { } catch (error) {
+3 -11
View File
@@ -3,14 +3,6 @@
"description": "Automated semver compliant package publishing", "description": "Automated semver compliant package publishing",
"version": "0.0.0-development", "version": "0.0.0-development",
"author": "Stephan Bönnemann <stephan@boennemann.me> (http://boennemann.me)", "author": "Stephan Bönnemann <stephan@boennemann.me> (http://boennemann.me)",
"ava": {
"files": [
"test/**/*.test.js"
],
"helpers": [
"test/helpers/**/*"
]
},
"bin": { "bin": {
"semantic-release": "bin/semantic-release.js" "semantic-release": "bin/semantic-release.js"
}, },
@@ -35,8 +27,8 @@
"aggregate-error": "^3.0.0", "aggregate-error": "^3.0.0",
"cosmiconfig": "^5.0.1", "cosmiconfig": "^5.0.1",
"debug": "^4.0.0", "debug": "^4.0.0",
"env-ci": "^4.0.0", "env-ci": "^3.0.0",
"execa": "^2.0.0", "execa": "^1.0.0",
"figures": "^3.0.0", "figures": "^3.0.0",
"find-versions": "^3.0.0", "find-versions": "^3.0.0",
"get-stream": "^5.0.0", "get-stream": "^5.0.0",
@@ -55,7 +47,7 @@
"yargs": "^13.1.0" "yargs": "^13.1.0"
}, },
"devDependencies": { "devDependencies": {
"ava": "^2.0.0", "ava": "^1.3.1",
"clear-module": "^3.0.0", "clear-module": "^3.0.0",
"codecov": "^3.0.0", "codecov": "^3.0.0",
"commitizen": "^3.0.0", "commitizen": "^3.0.0",
+1 -1
View File
@@ -482,6 +482,6 @@ test('Throw an Error if one of the shareable config cannot be found', async t =>
const error = await t.throwsAsync(t.context.getConfig({cwd}), Error); const error = await t.throwsAsync(t.context.getConfig({cwd}), Error);
t.regex(error.message, /Cannot find module 'non-existing-path'/); t.is(error.message, "Cannot find module 'non-existing-path'");
t.is(error.code, 'MODULE_NOT_FOUND'); t.is(error.code, 'MODULE_NOT_FOUND');
}); });
+9 -11
View File
@@ -69,10 +69,8 @@ export async function initBareRepo(repositoryUrl, branch = 'master') {
* @returns {Array<Commit>} The created commits, in reverse order (to match `git log` order). * @returns {Array<Commit>} The created commits, in reverse order (to match `git log` order).
*/ */
export async function gitCommits(messages, execaOpts) { export async function gitCommits(messages, execaOpts) {
await pReduce( await pReduce(messages, (_, message) =>
messages, execa.stdout('git', ['commit', '-m', message, '--allow-empty', '--no-gpg-sign'], execaOpts)
async (_, message) =>
(await execa('git', ['commit', '-m', message, '--allow-empty', '--no-gpg-sign'], execaOpts)).stdout
); );
return (await gitGetCommits(undefined, execaOpts)).slice(0, messages.length); return (await gitGetCommits(undefined, execaOpts)).slice(0, messages.length);
} }
@@ -114,8 +112,8 @@ export async function gitCheckout(branch, create = true, execaOpts) {
* *
* @return {String} The sha of the head commit in the current git repository. * @return {String} The sha of the head commit in the current git repository.
*/ */
export async function gitHead(execaOpts) { export function gitHead(execaOpts) {
return (await execa('git', ['rev-parse', 'HEAD'], execaOpts)).stdout; return execa.stdout('git', ['rev-parse', 'HEAD'], execaOpts);
} }
/** /**
@@ -183,8 +181,8 @@ export async function gitAddConfig(name, value, execaOpts) {
* *
* @return {String} The sha of the commit associated with `tagName` on the local repository. * @return {String} The sha of the commit associated with `tagName` on the local repository.
*/ */
export async function gitTagHead(tagName, execaOpts) { export function gitTagHead(tagName, execaOpts) {
return (await execa('git', ['rev-list', '-1', tagName], execaOpts)).stdout; return execa.stdout('git', ['rev-list', '-1', tagName], execaOpts);
} }
/** /**
@@ -197,7 +195,7 @@ export async function gitTagHead(tagName, execaOpts) {
* @return {String} The sha of the commit associated with `tagName` on the remote repository. * @return {String} The sha of the commit associated with `tagName` on the remote repository.
*/ */
export async function gitRemoteTagHead(repositoryUrl, tagName, execaOpts) { export async function gitRemoteTagHead(repositoryUrl, tagName, execaOpts) {
return (await execa('git', ['ls-remote', '--tags', repositoryUrl, tagName], execaOpts)).stdout return (await execa.stdout('git', ['ls-remote', '--tags', repositoryUrl, tagName], execaOpts))
.split('\n') .split('\n')
.filter(tag => Boolean(tag)) .filter(tag => Boolean(tag))
.map(tag => tag.match(/^(\S+)/)[1])[0]; .map(tag => tag.match(/^(\S+)/)[1])[0];
@@ -211,8 +209,8 @@ export async function gitRemoteTagHead(repositoryUrl, tagName, execaOpts) {
* *
* @return {String} The tag associatedwith the sha in parameter or `null`. * @return {String} The tag associatedwith the sha in parameter or `null`.
*/ */
export async function gitCommitTag(gitHead, execaOpts) { export function gitCommitTag(gitHead, execaOpts) {
return (await execa('git', ['describe', '--tags', '--exact-match', gitHead], execaOpts)).stdout; return execa.stdout('git', ['describe', '--tags', '--exact-match', gitHead], execaOpts);
} }
/** /**
+28 -28
View File
@@ -72,9 +72,9 @@ test('Release patch, minor and major versions', async t => {
t.log('Commit a chore'); t.log('Commit a chore');
await gitCommits(['chore: Init repository'], {cwd}); await gitCommits(['chore: Init repository'], {cwd});
t.log('$ semantic-release'); t.log('$ semantic-release');
let {stdout, exitCode} = await execa(cli, [], {env, cwd}); let {stdout, code} = await execa(cli, [], {env, cwd});
t.regex(stdout, /There are no relevant changes, so no new version is released/); t.regex(stdout, /There are no relevant changes, so no new version is released/);
t.is(exitCode, 0); t.is(code, 0);
/* Initial release */ /* Initial release */
let version = '1.0.0'; let version = '1.0.0';
@@ -95,10 +95,10 @@ test('Release patch, minor and major versions', async t => {
t.log('Commit a feature'); t.log('Commit a feature');
await gitCommits(['feat: Initial commit'], {cwd}); await gitCommits(['feat: Initial commit'], {cwd});
t.log('$ semantic-release'); t.log('$ semantic-release');
({stdout, exitCode} = await execa(cli, [], {env, cwd})); ({stdout, code} = await execa(cli, [], {env, cwd}));
t.regex(stdout, new RegExp(`Published GitHub release: release-url/${version}`)); t.regex(stdout, new RegExp(`Published GitHub release: release-url/${version}`));
t.regex(stdout, new RegExp(`Publishing version ${version} to npm registry`)); t.regex(stdout, new RegExp(`Publishing version ${version} to npm registry`));
t.is(exitCode, 0); t.is(code, 0);
// Verify package.json and npm-shrinkwrap.json have been updated // Verify package.json and npm-shrinkwrap.json have been updated
t.is((await readJson(path.resolve(cwd, 'package.json'))).version, version); t.is((await readJson(path.resolve(cwd, 'package.json'))).version, version);
@@ -137,10 +137,10 @@ test('Release patch, minor and major versions', async t => {
t.log('Commit a fix'); t.log('Commit a fix');
await gitCommits(['fix: bar'], {cwd}); await gitCommits(['fix: bar'], {cwd});
t.log('$ semantic-release'); t.log('$ semantic-release');
({stdout, exitCode} = await execa(cli, [], {env, cwd})); ({stdout, code} = await execa(cli, [], {env, cwd}));
t.regex(stdout, new RegExp(`Published GitHub release: release-url/${version}`)); t.regex(stdout, new RegExp(`Published GitHub release: release-url/${version}`));
t.regex(stdout, new RegExp(`Publishing version ${version} to npm registry`)); t.regex(stdout, new RegExp(`Publishing version ${version} to npm registry`));
t.is(exitCode, 0); t.is(code, 0);
// Verify package.json and npm-shrinkwrap.json have been updated // Verify package.json and npm-shrinkwrap.json have been updated
t.is((await readJson(path.resolve(cwd, 'package.json'))).version, version); t.is((await readJson(path.resolve(cwd, 'package.json'))).version, version);
@@ -179,10 +179,10 @@ test('Release patch, minor and major versions', async t => {
t.log('Commit a feature'); t.log('Commit a feature');
await gitCommits(['feat: baz'], {cwd}); await gitCommits(['feat: baz'], {cwd});
t.log('$ semantic-release'); t.log('$ semantic-release');
({stdout, exitCode} = await execa(cli, [], {env, cwd})); ({stdout, code} = await execa(cli, [], {env, cwd}));
t.regex(stdout, new RegExp(`Published GitHub release: release-url/${version}`)); t.regex(stdout, new RegExp(`Published GitHub release: release-url/${version}`));
t.regex(stdout, new RegExp(`Publishing version ${version} to npm registry`)); t.regex(stdout, new RegExp(`Publishing version ${version} to npm registry`));
t.is(exitCode, 0); t.is(code, 0);
// Verify package.json and npm-shrinkwrap.json have been updated // Verify package.json and npm-shrinkwrap.json have been updated
t.is((await readJson(path.resolve(cwd, 'package.json'))).version, version); t.is((await readJson(path.resolve(cwd, 'package.json'))).version, version);
@@ -221,10 +221,10 @@ test('Release patch, minor and major versions', async t => {
t.log('Commit a breaking change'); t.log('Commit a breaking change');
await gitCommits(['feat: foo\n\n BREAKING CHANGE: bar'], {cwd}); await gitCommits(['feat: foo\n\n BREAKING CHANGE: bar'], {cwd});
t.log('$ semantic-release'); t.log('$ semantic-release');
({stdout, exitCode} = await execa(cli, [], {env, cwd})); ({stdout, code} = await execa(cli, [], {env, cwd}));
t.regex(stdout, new RegExp(`Published GitHub release: release-url/${version}`)); t.regex(stdout, new RegExp(`Published GitHub release: release-url/${version}`));
t.regex(stdout, new RegExp(`Publishing version ${version} to npm registry`)); t.regex(stdout, new RegExp(`Publishing version ${version} to npm registry`));
t.is(exitCode, 0); t.is(code, 0);
// Verify package.json and npm-shrinkwrap.json have been updated // Verify package.json and npm-shrinkwrap.json have been updated
t.is((await readJson(path.resolve(cwd, 'package.json'))).version, version); t.is((await readJson(path.resolve(cwd, 'package.json'))).version, version);
@@ -258,8 +258,8 @@ test('Exit with 1 if a plugin is not found', async t => {
release: {analyzeCommits: 'non-existing-path', success: false, fail: false}, release: {analyzeCommits: 'non-existing-path', success: false, fail: false},
}); });
const {exitCode, stderr} = await t.throwsAsync(execa(cli, [], {env, cwd})); const {code, stderr} = await t.throwsAsync(execa(cli, [], {env, cwd}));
t.is(exitCode, 1); t.is(code, 1);
t.regex(stderr, /Cannot find module/); t.regex(stderr, /Cannot find module/);
}); });
@@ -276,8 +276,8 @@ test('Exit with 1 if a shareable config is not found', async t => {
release: {extends: 'non-existing-path', success: false, fail: false}, release: {extends: 'non-existing-path', success: false, fail: false},
}); });
const {exitCode, stderr} = await t.throwsAsync(execa(cli, [], {env, cwd})); const {code, stderr} = await t.throwsAsync(execa(cli, [], {env, cwd}));
t.is(exitCode, 1); t.is(code, 1);
t.regex(stderr, /Cannot find module/); t.regex(stderr, /Cannot find module/);
}); });
@@ -297,8 +297,8 @@ test('Exit with 1 if a shareable config reference a not found plugin', async t =
}); });
await writeJson(path.resolve(cwd, 'shareable.json'), shareable); await writeJson(path.resolve(cwd, 'shareable.json'), shareable);
const {exitCode, stderr} = await t.throwsAsync(execa(cli, [], {env, cwd})); const {code, stderr} = await t.throwsAsync(execa(cli, [], {env, cwd}));
t.is(exitCode, 1); t.is(code, 1);
t.regex(stderr, /Cannot find module/); t.regex(stderr, /Cannot find module/);
}); });
@@ -327,11 +327,11 @@ test('Dry-run', async t => {
t.log('Commit a feature'); t.log('Commit a feature');
await gitCommits(['feat: Initial commit'], {cwd}); await gitCommits(['feat: Initial commit'], {cwd});
t.log('$ semantic-release -d'); t.log('$ semantic-release -d');
const {stdout, exitCode} = await execa(cli, ['-d'], {env, cwd}); const {stdout, code} = await execa(cli, ['-d'], {env, cwd});
t.regex(stdout, new RegExp(`There is no previous release, the next release version is ${version}`)); t.regex(stdout, new RegExp(`There is no previous release, the next release version is ${version}`));
t.regex(stdout, new RegExp(`Release note for version ${version}`)); t.regex(stdout, new RegExp(`Release note for version ${version}`));
t.regex(stdout, /Initial commit/); t.regex(stdout, /Initial commit/);
t.is(exitCode, 0); t.is(code, 0);
// Verify package.json and has not been modified // Verify package.json and has not been modified
t.is((await readJson(path.resolve(cwd, 'package.json'))).version, '0.0.0-dev'); t.is((await readJson(path.resolve(cwd, 'package.json'))).version, '0.0.0-dev');
@@ -375,10 +375,10 @@ test('Allow local releases with "noCi" option', async t => {
t.log('Commit a feature'); t.log('Commit a feature');
await gitCommits(['feat: Initial commit'], {cwd}); await gitCommits(['feat: Initial commit'], {cwd});
t.log('$ semantic-release --no-ci'); t.log('$ semantic-release --no-ci');
const {stdout, exitCode} = await execa(cli, ['--no-ci'], {env: envNoCi, cwd}); const {stdout, code} = await execa(cli, ['--no-ci'], {env: envNoCi, cwd});
t.regex(stdout, new RegExp(`Published GitHub release: release-url/${version}`)); t.regex(stdout, new RegExp(`Published GitHub release: release-url/${version}`));
t.regex(stdout, new RegExp(`Publishing version ${version} to npm registry`)); t.regex(stdout, new RegExp(`Publishing version ${version} to npm registry`));
t.is(exitCode, 0); t.is(code, 0);
// Verify package.json and has been updated // Verify package.json and has been updated
t.is((await readJson(path.resolve(cwd, 'package.json'))).version, version); t.is((await readJson(path.resolve(cwd, 'package.json'))).version, version);
@@ -417,7 +417,7 @@ test('Pass options via CLI arguments', async t => {
t.log('Commit a feature'); t.log('Commit a feature');
await gitCommits(['feat: Initial commit'], {cwd}); await gitCommits(['feat: Initial commit'], {cwd});
t.log('$ semantic-release'); t.log('$ semantic-release');
const {stdout, exitCode} = await execa( const {stdout, code} = await execa(
cli, cli,
[ [
'--verify-conditions', '--verify-conditions',
@@ -433,7 +433,7 @@ test('Pass options via CLI arguments', async t => {
{env, cwd} {env, cwd}
); );
t.regex(stdout, new RegExp(`Publishing version ${version} to npm registry`)); t.regex(stdout, new RegExp(`Publishing version ${version} to npm registry`));
t.is(exitCode, 0); t.is(code, 0);
// Verify package.json and has been updated // Verify package.json and has been updated
t.is((await readJson(path.resolve(cwd, 'package.json'))).version, version); t.is((await readJson(path.resolve(cwd, 'package.json'))).version, version);
@@ -528,14 +528,14 @@ test('Log unexpected errors from plugins and exit with 1', async t => {
t.log('Commit a feature'); t.log('Commit a feature');
await gitCommits(['feat: Initial commit'], {cwd}); await gitCommits(['feat: Initial commit'], {cwd});
t.log('$ semantic-release'); t.log('$ semantic-release');
const {stderr, exitCode} = await execa(cli, [], {env, cwd, reject: false}); const {stderr, code} = await execa(cli, [], {env, cwd, reject: false});
// Verify the type and message are logged // Verify the type and message are logged
t.regex(stderr, /Error: a/); t.regex(stderr, /Error: a/);
// Verify the the stacktrace is logged // Verify the the stacktrace is logged
t.regex(stderr, new RegExp(pluginError)); t.regex(stderr, new RegExp(pluginError));
// Verify the Error properties are logged // Verify the Error properties are logged
t.regex(stderr, /errorProperty: 'errorProperty'/); t.regex(stderr, /errorProperty: 'errorProperty'/);
t.is(exitCode, 1); t.is(code, 1);
}); });
test('Log errors inheriting SemanticReleaseError and exit with 1', async t => { test('Log errors inheriting SemanticReleaseError and exit with 1', async t => {
@@ -555,10 +555,10 @@ test('Log errors inheriting SemanticReleaseError and exit with 1', async t => {
t.log('Commit a feature'); t.log('Commit a feature');
await gitCommits(['feat: Initial commit'], {cwd}); await gitCommits(['feat: Initial commit'], {cwd});
t.log('$ semantic-release'); t.log('$ semantic-release');
const {stderr, exitCode} = await execa(cli, [], {env, cwd, reject: false}); const {stderr, code} = await execa(cli, [], {env, cwd, reject: false});
// Verify the type and message are logged // Verify the type and message are logged
t.regex(stderr, /EINHERITED Inherited error/); t.regex(stderr, /EINHERITED Inherited error/);
t.is(exitCode, 1); t.is(code, 1);
}); });
test('Exit with 1 if missing permission to push to the remote repository', async t => { test('Exit with 1 if missing permission to push to the remote repository', async t => {
@@ -573,14 +573,14 @@ test('Exit with 1 if missing permission to push to the remote repository', async
await gitCommits(['feat: Initial commit'], {cwd}); await gitCommits(['feat: Initial commit'], {cwd});
await gitPush('origin', 'master', {cwd}); await gitPush('origin', 'master', {cwd});
t.log('$ semantic-release'); t.log('$ semantic-release');
const {stderr, exitCode} = await execa( const {stderr, code} = await execa(
cli, cli,
['--repository-url', 'http://user:wrong_pass@localhost:2080/git/unauthorized.git'], ['--repository-url', 'http://user:wrong_pass@localhost:2080/git/unauthorized.git'],
{env: {...env, GH_TOKEN: 'user:wrong_pass'}, cwd, reject: false} {env: {...env, GH_TOKEN: 'user:wrong_pass'}, cwd, reject: false}
); );
// Verify the type and message are logged // Verify the type and message are logged
t.regex(stderr, /EGITNOPERMISSION/); t.regex(stderr, /EGITNOPERMISSION/);
t.is(exitCode, 1); t.is(code, 1);
}); });
test('Hide sensitive environment variable values from the logs', async t => { test('Hide sensitive environment variable values from the logs', async t => {
+1 -1
View File
@@ -255,6 +255,6 @@ test('Throws an error if the plugin is not found', t => {
Error Error
); );
t.regex(error.message, /Cannot find module 'non-existing-path'/); t.is(error.message, "Cannot find module 'non-existing-path'");
t.is(error.code, 'MODULE_NOT_FOUND'); t.is(error.code, 'MODULE_NOT_FOUND');
}); });