Skip to content

Commit

Permalink
Housekeeping
Browse files Browse the repository at this point in the history
  • Loading branch information
webpro committed Dec 12, 2018
1 parent 70fe41b commit f34a3a2
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 16 deletions.
2 changes: 1 addition & 1 deletion lib/git.js
Expand Up @@ -4,7 +4,7 @@ const _ = require('lodash');
const { format } = require('./util');
const { run, runTemplateCommand } = require('./shell');
const { config } = require('./config');
const { log, warn, logError } = require('./log');
const { warn, logError } = require('./log');
const { GitCloneError, GitCommitError, CreateChangelogError } = require('./errors');
const { debugGit } = require('./debug');

Expand Down
4 changes: 1 addition & 3 deletions lib/recommendations.js
@@ -1,14 +1,12 @@
const conventionalRecommendedBump = require('conventional-recommended-bump');

const isValidSystem = ({ system }) => system === 'conventional';

const getConventionalRecommendedBump = preset =>
new Promise((resolve, reject) => {
conventionalRecommendedBump(
{
preset
},
function(err, result) {
(err, result) => {
if (err) return reject(err);
resolve(result.releaseType);
}
Expand Down
8 changes: 2 additions & 6 deletions lib/shell.js
Expand Up @@ -50,13 +50,9 @@ const runTemplateCommand = (command, options = { verbose: true }) => {
return command ? run(format(command), options) : noop;
};

const pushd = path => {
return run(`!pushd ${path}`, { isReadOnly: true });
};
const pushd = path => run(`!pushd ${path}`, { isReadOnly: true });

const popd = () => {
return run('!popd', { isReadOnly: true });
};
const popd = () => run('!popd', { isReadOnly: true });

const npmPublish = (options, pkgName, otpPrompt) => {
const { publishPath, tag, access, otp } = options;
Expand Down
3 changes: 2 additions & 1 deletion lib/spinner.js
@@ -1,5 +1,6 @@
const ora = require('ora');
const { config } = require('./config');
const { log } = require('./log');
const { debugConfig } = require('./debug');

const showSpinner = !config.isInteractive && !config.isVerbose && !config.isDryRun && !debugConfig.enabled;
Expand All @@ -15,7 +16,7 @@ const spinner = showSpinner
warn: () => spinner,
fail: () => spinner,
stopAndPersist: ({ symbol, text }) => {
console.log(symbol, text);
log(symbol, text);
return spinner;
}
};
Expand Down
2 changes: 1 addition & 1 deletion lib/tasks.js
Expand Up @@ -10,7 +10,7 @@ const { truncateLines } = require('./util');
const { parse: parseVersion } = require('./version');
const { getIsLateChangeLog } = require('./recommendations');
const { config } = require('./config');
const { log, info, warn, logError } = require('./log');
const { info, warn, logError } = require('./log');
const { debug, debugConfig } = require('./debug');
const { spinner, getSpinner } = require('./spinner');
const handleDeprecated = require('./deprecated');
Expand Down
3 changes: 2 additions & 1 deletion lib/version.js
Expand Up @@ -60,13 +60,14 @@ const parse = async options => {
case isValidType:
result.version = semver.inc(latestVersion, normalizedType, preReleaseId);
break;
default:
default: {
const coercedVersion = !isValid(increment) && semver.coerce(increment);
if (coercedVersion) {
result.version = coercedVersion.toString();
warn(`Coerced invalid semver version "${increment}" into "${result.version}".`);
}
break;
}
}

return result;
Expand Down
2 changes: 1 addition & 1 deletion test/shell.js
Expand Up @@ -66,7 +66,7 @@ test('pushd + popd', async t => {
const [to, from] = outputPush.split(',');
const diff = to
.replace(from, '')
.replace(/^[\/|\\\\]/, '')
.replace(/^[/|\\\\]/, '')
.replace(/\\/g, '/');
t.equal(diff, dir);
const popOutput = await popd();
Expand Down
4 changes: 2 additions & 2 deletions test/version.js
Expand Up @@ -5,7 +5,7 @@ const mockStdIo = require('mock-stdio');
const { run } = require('../lib/shell');
const { isValid, isPreRelease } = require('../lib/version');

const getLatestTag = (version = '1.0.0') => ({ getLatestTag: () => version });
const getLatestTag = version => ({ getLatestTag: () => version });
const getRecommendedType = (type = null) => ({ getRecommendedType: () => type });

const getMock = (git = getLatestTag(), recommendations = {}) =>
Expand Down Expand Up @@ -224,7 +224,7 @@ test('parse (invalid npm version)', async t => {
});

test('parse (coerce)', async t => {
const { parse } = getMock();
const { parse } = getMock(getLatestTag('1.0.0'));
mockStdIo.start();
t.deepEqual(await parse({ increment: '2' }), {
latestVersion: '1.0.0',
Expand Down

0 comments on commit f34a3a2

Please sign in to comment.