Skip to content

Commit

Permalink
Don't start with --local if sdm-local is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
cdupuis committed Aug 21, 2018
1 parent f47c15f commit 242882d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
5 changes: 1 addition & 4 deletions src/internal/machine/LocalModeConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* limitations under the License.
*/

import { logger } from "@atomist/automation-client";
import { PushTest } from "@atomist/sdm";

/**
Expand Down Expand Up @@ -47,9 +46,7 @@ export interface LocalModeConfiguration {
* Invoked on client startup.
*/
export function isInLocalMode(): boolean {
const local = process.env.ATOMIST_MODE === "local";
logger.info("Local determination is %s: startup command was '%s'", local, process.argv.join(" "));
return local;
return process.env.ATOMIST_MODE === "local";
}

/**
Expand Down
17 changes: 11 additions & 6 deletions src/internal/machine/configureSdm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ import {
sdmExtensionPackStartupMessage,
sdmStartupMessage,
} from "../util/startupMessage";
import { LocalModeConfiguration } from "./LocalModeConfiguration";
import {
isInLocalMode,
LocalModeConfiguration,
} from "./LocalModeConfiguration";

/**
* Options that are used during configuration of an SDM but don't get passed on to the
Expand All @@ -52,7 +55,7 @@ export interface ConfigureOptions {
export type SoftwareDeliveryMachineMaker = (configuration: SoftwareDeliveryMachineConfiguration) => SoftwareDeliveryMachine;

/**
* Configure and set up a Software Deliver Machine instance with the automation-client framework for standalone
* Configure and set up a Software Delivery Machine instance with the automation-client framework for standalone
* or single goal based execution
* @param {(configuration: (Configuration & SoftwareDeliveryMachineOptions)) => SoftwareDeliveryMachine} machineMaker
* @param {ConfigureOptions} options
Expand Down Expand Up @@ -181,10 +184,12 @@ async function registerMetadata(config: Configuration, machine: SoftwareDelivery
*/
async function doWithSdmLocal(callback: (sdmLocal: any) => any) {
try {
const local = require("@atomist/sdm-local");
return callback(local);

if (isInLocalMode()) {
const local = require("@atomist/sdm-local");
return callback(local);
}
} catch (err) {
// Nothing to report here
throw new Error("SDM started in local mode, but '@atomist/sdm-local' not declared as dependency. " +
"Please install SDM local with 'npm install @atomist/sdm-local'.");
}
}

0 comments on commit 242882d

Please sign in to comment.