Skip to content
Permalink
Browse files

refactor(publisher): rename target option to publishTargets in API

BREAKING CHANGE: publish API option name renamed, only takes an Array of Strings.
  • Loading branch information
malept committed Aug 26, 2017
1 parent f445982 commit 4b68880d9d9ea63efe3e9d2b9d46655df0960cf4
Showing with 7 additions and 14 deletions.
  1. +3 −10 src/api/publish.js
  2. +2 −2 src/electron-forge-publish.js
  3. +2 −2 test/fast/publish_spec.js
@@ -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';
@@ -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()
*/

@@ -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,
@@ -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) {
@@ -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;
@@ -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();

@@ -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');
});
@@ -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');

0 comments on commit 4b68880

Please sign in to comment.
You can’t perform that action at this time.