@theo.gravity/version-bump
Advanced tools
Comparing version 1.0.19 to 1.0.21
@@ -0,1 +1,5 @@ | ||
# 1.0.21 - Thu Sep 20 2018 07:42:35 | ||
Fix bugs with binary | ||
# 1.0.19 - Thu Sep 20 2018 05:38:07 | ||
@@ -2,0 +6,0 @@ |
@@ -31,9 +31,10 @@ "use strict"; | ||
expect(options).toEqual({ | ||
'bump': 'minor', | ||
'configFile': '__fixtures__/config-example.js', | ||
'projectRoot': process.cwd(), | ||
'strategy': 'cli', | ||
'versionFile': 'test.json' | ||
bump: 'minor', | ||
configFile: '__fixtures__/config-example.js', | ||
projectRoot: process.cwd(), | ||
strategy: 'cli', | ||
versionFile: 'test.json', | ||
_usingConfig: true | ||
}); | ||
}); | ||
}); |
@@ -24,3 +24,5 @@ #!/usr/bin/env node | ||
// eslint-disable-next-line no-unused-expressions | ||
let cli = _yargs.default.version(packageData.version).usage('version-bump <strategy>').wrap(120).options({ | ||
let cli = _yargs.default.version(packageData.version).usage('$0 <strategy>').updateStrings({ | ||
'Commands:': 'Versioning Strategies:\n' | ||
}).wrap(120).options({ | ||
projectRoot: { | ||
@@ -37,3 +39,3 @@ describe: 'The project root where the version file is found. Default is process.cwd()', | ||
} | ||
}); | ||
}).example('$0 cli major').example('$0 cli --bump minor'); | ||
@@ -61,9 +63,17 @@ cli.command('show-version', '(not a strategy) Reads the version and outputs it.', yargs => { | ||
cli = cli.config(options); | ||
cli = cli.config(options); // when built as a standalone binary, strategy does not seem to be registered | ||
// so capture what the strategy is here | ||
if (!options.strategy) { | ||
const strategy = options.strategy || options._[0]; | ||
if (!strategy && !options._usingConfig) { | ||
cli.showHelp(); | ||
throw new Error('A strategy was not specified, or the specified config file could not be found.'); | ||
} else if (strategy === 'show-version') { | ||
// show-version is not a strategy, run it as a normal yargs command | ||
// eslint-disable-next-line no-unused-expressions | ||
cli.argv; | ||
} else { | ||
if (!loader.strategyExists(options.strategy)) { | ||
throw new Error('Strategy does not exist: ' + options.strategy); | ||
if (!loader.strategyExists(strategy)) { | ||
throw new Error(`Strategy does not exist: ${strategy}. Use --help to see a list of strategies.`); | ||
} // Execute the strategy | ||
@@ -73,3 +83,3 @@ // eslint-disable-next-line no-unused-expressions | ||
cli.parse([options.strategy]).argv; | ||
cli.parse([strategy]).argv; | ||
} | ||
@@ -76,0 +86,0 @@ } |
@@ -72,3 +72,5 @@ "use strict"; | ||
const calculatedOptions = await (0, _utils.parseOptions)(options, CONFIG_OPTIONS_TO_SKIP); | ||
defaultOptions = _objectSpread({}, calculatedOptions, this.options, { | ||
defaultOptions = _objectSpread({ | ||
_usingConfig: true | ||
}, calculatedOptions, this.options, { | ||
// Speical case: if the config file has projectRoot, | ||
@@ -75,0 +77,0 @@ // use that value instead, even if it's specified on the |
{ | ||
"name": "@theo.gravity/version-bump", | ||
"version": "1.0.19", | ||
"version": "1.0.21", | ||
"description": "Version bump package.json (or a version file) via various plugins (eg cli, git, etc).", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -33,9 +33,10 @@ /* eslint-env jest */ | ||
expect(options).toEqual({ | ||
'bump': 'minor', | ||
'configFile': '__fixtures__/config-example.js', | ||
'projectRoot': process.cwd(), | ||
'strategy': 'cli', | ||
'versionFile': 'test.json' | ||
bump: 'minor', | ||
configFile: '__fixtures__/config-example.js', | ||
projectRoot: process.cwd(), | ||
strategy: 'cli', | ||
versionFile: 'test.json', | ||
_usingConfig: true | ||
}) | ||
}) | ||
}) |
@@ -19,3 +19,6 @@ #!/usr/bin/env node | ||
.version(packageData.version) | ||
.usage('version-bump <strategy>') | ||
.usage('$0 <strategy>') | ||
.updateStrings({ | ||
'Commands:': 'Versioning Strategies:\n' | ||
}) | ||
.wrap(120) | ||
@@ -38,2 +41,4 @@ .options({ | ||
}) | ||
.example('$0 cli major') | ||
.example('$0 cli --bump minor') | ||
@@ -74,7 +79,21 @@ cli.command( | ||
if (!options.strategy) { | ||
// when built as a standalone binary, strategy does not seem to be registered | ||
// so capture what the strategy is here | ||
const strategy = options.strategy || options._[0] | ||
if (!strategy && !options._usingConfig) { | ||
cli.showHelp() | ||
throw new Error( | ||
'A strategy was not specified, or the specified config file could not be found.' | ||
) | ||
} else if (strategy === 'show-version') { | ||
// show-version is not a strategy, run it as a normal yargs command | ||
// eslint-disable-next-line no-unused-expressions | ||
cli.argv | ||
} else { | ||
if (!loader.strategyExists(options.strategy)) { | ||
throw new Error('Strategy does not exist: ' + options.strategy) | ||
if (!loader.strategyExists(strategy)) { | ||
throw new Error( | ||
`Strategy does not exist: ${strategy}. Use --help to see a list of strategies.` | ||
) | ||
} | ||
@@ -84,3 +103,3 @@ | ||
// eslint-disable-next-line no-unused-expressions | ||
cli.parse([options.strategy]).argv | ||
cli.parse([strategy]).argv | ||
} | ||
@@ -87,0 +106,0 @@ } |
@@ -6,3 +6,3 @@ import { join } from 'path' | ||
} from 'fs' | ||
import {getValue, parseOptions} from './utils' | ||
import { getValue, parseOptions } from './utils' | ||
@@ -57,5 +57,9 @@ const debug = require('debug')('config-parser') | ||
const calculatedOptions = await parseOptions(options, CONFIG_OPTIONS_TO_SKIP) | ||
const calculatedOptions = await parseOptions( | ||
options, | ||
CONFIG_OPTIONS_TO_SKIP | ||
) | ||
defaultOptions = { | ||
_usingConfig: true, | ||
...calculatedOptions, | ||
@@ -62,0 +66,0 @@ ...this.options, |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
308645
3169