Skip to content

Commit

Permalink
refactor(publisher): rename target option to publishTargets in API
Browse files Browse the repository at this point in the history
BREAKING CHANGE: publish API option name renamed, only takes an Array of Strings.
  • Loading branch information
malept committed Aug 27, 2017
1 parent f445982 commit 4b68880
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
13 changes: 3 additions & 10 deletions src/api/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import 'colors';
import path from 'path';

import asyncOra from '../util/ora-handler';
import deprecate from '../util/deprecate';
import getForgeConfig from '../util/forge-config';
import readPackageJSON from '../util/read-package-json';
import requireSearch from '../util/require-search';
Expand All @@ -16,7 +15,7 @@ import make from './make';
* @property {boolean} [interactive=false] Whether to use sensible defaults or prompt the user visually
* @property {string} [authToken] An authentication token to use when publishing
* @property {string} [tag=packageJSON.version] The string to tag this release with
* @property {string} [target=github] The publish target
* @property {Array<string>} [publishTargets=[github]] The publish targets
* @property {MakeOptions} [makeOptions] Options object to passed through to make()
*/

Expand All @@ -28,16 +27,14 @@ import make from './make';
*/
export default async (providedOptions = {}) => {
// eslint-disable-next-line prefer-const, no-unused-vars
let { dir, interactive, authToken, tag, target, makeOptions } = Object.assign({
let { dir, interactive, authToken, tag, publishTargets, makeOptions } = Object.assign({
dir: process.cwd(),
interactive: false,
tag: null,
makeOptions: {},
target: null,
publishTargets: null,
}, providedOptions);
asyncOra.interactive = interactive;
// FIXME(MarshallOfSound): Change the method param to publishTargets in the next major bump
let publishTargets = target;

const makeResults = await make(Object.assign({
dir,
Expand All @@ -60,10 +57,6 @@ export default async (providedOptions = {}) => {

if (publishTargets === null) {
publishTargets = forgeConfig.publish_targets[makeOptions.platform || process.platform];
} else if (typeof publishTargets === 'string') {
// FIXME(MarshallOfSound): Remove this fallback string typeof check in the next major bump
deprecate('publish target as a string').replaceWith('an array of publish targets');
publishTargets = [publishTargets];
}

for (const publishTarget of publishTargets) {
Expand Down
4 changes: 2 additions & 2 deletions src/electron-forge-publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { getMakeOptions } from './electron-forge-make';
.arguments('[cwd]')
.option('--auth-token', 'Authorization token for your publisher target (if required)')
.option('--tag', 'The tag to publish to on GitHub')
.option('--target [target]', 'The deployment target, defaults to "github"')
.option('--target [target[,target...]]', 'The comma-separated deployment targets, defaults to "github"')
.allowUnknownOption(true)
.action((cwd) => {
if (!cwd) return;
Expand All @@ -31,7 +31,7 @@ import { getMakeOptions } from './electron-forge-make';
authToken: program.authToken,
tag: program.tag,
};
if (program.target) publishOpts.target = program.target.split(',');
if (program.target) publishOpts.publishTargets = program.target.split(',');

publishOpts.makeOptions = getMakeOptions();

Expand Down
4 changes: 2 additions & 2 deletions test/fast/publish_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe('publish', () => {
await publish({
dir: __dirname,
interactive: false,
target: 'void',
publishTargets: ['void'],
});
expect(requireSearchStub.firstCall.args[1][0]).to.equal('../publishers/void.js');
});
Expand All @@ -81,7 +81,7 @@ describe('publish', () => {
await publish({
dir: __dirname,
interactive: false,
target: ['void', 'nowhere', 'black_hole', 'everywhere'],
publishTargets: ['void', 'nowhere', 'black_hole', 'everywhere'],
});
expect(requireSearchStub.getCall(0).args[1][0]).to.equal('../publishers/void.js');
expect(requireSearchStub.getCall(1).args[1][0]).to.equal('../publishers/nowhere.js');
Expand Down

0 comments on commit 4b68880

Please sign in to comment.