Skip to content

Commit 1142925

Browse files
committed
Addressed comments
1 parent 7ae4e28 commit 1142925

File tree

2 files changed

+13
-18
lines changed

2 files changed

+13
-18
lines changed

src/init/features/dataconnect/sdk.spec.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { expect } from "chai";
55
import * as sdk from "./sdk";
66
import { DataConnectEmulator } from "../../../emulator/dataconnectEmulator";
77
import { Config } from "../../../config";
8-
import { FIXTURE_DIR } from "../../../test/fixtures/config-imports";
98

109
const CONNECTOR_YAML_CONTENTS = "connectorId: blah";
1110

@@ -18,10 +17,14 @@ describe("init dataconnect:sdk", () => {
1817
const sandbox = sinon.createSandbox();
1918
let generateStub: sinon.SinonStub;
2019
let fsStub: sinon.SinonStub;
20+
let emptyConfig: Config;
21+
let askProjectWriteFileStub: sinon.SinonStub;
2122

2223
beforeEach(() => {
2324
fsStub = sandbox.stub(fs, "writeFileSync");
2425
generateStub = sandbox.stub(DataConnectEmulator, "generate");
26+
emptyConfig = new Config({}, { projectDir: process.cwd() });
27+
askProjectWriteFileStub = sandbox.stub(emptyConfig, "askWriteProjectFile");
2528
});
2629

2730
afterEach(() => {
@@ -44,14 +47,11 @@ describe("init dataconnect:sdk", () => {
4447
it(c.desc, async () => {
4548
generateStub.resolves();
4649
fsStub.returns({});
47-
await sdk.actuate(c.sdkInfo, new Config({}, { cwd: FIXTURE_DIR }), true);
50+
51+
await sdk.actuate(c.sdkInfo, emptyConfig);
4852
expect(generateStub.called).to.equal(c.shouldGenerate);
49-
expect(fsStub.args).to.deep.equal([
50-
[
51-
`${process.cwd()}/dataconnect/connector/connector.yaml`,
52-
CONNECTOR_YAML_CONTENTS,
53-
"utf8",
54-
],
53+
expect(askProjectWriteFileStub.args).to.deep.equal([
54+
["dataconnect/connector/connector.yaml", CONNECTOR_YAML_CONTENTS],
5555
]);
5656
});
5757
}

src/init/features/dataconnect/sdk.ts

+5-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as yaml from "yaml";
22
import * as clc from "colorette";
3-
import * as fs from "fs";
43
import * as path from "path";
54

65
import { dirExistsSync } from "../../../fsutils";
@@ -224,17 +223,13 @@ export async function generateSdkYaml(
224223
return connectorYaml;
225224
}
226225

227-
export async function actuate(sdkInfo: SDKInfo, config: Config, skipCheck?: boolean) {
226+
export async function actuate(sdkInfo: SDKInfo, config: Config) {
228227
const connectorYamlPath = `${sdkInfo.connectorInfo.directory}/connector.yaml`;
229228
logBullet(`Writing your new SDK configuration to ${connectorYamlPath}`);
230-
if (skipCheck) {
231-
fs.writeFileSync(connectorYamlPath, sdkInfo.connectorYamlContents);
232-
} else {
233-
await config.askWriteProjectFile(
234-
path.relative(config.projectDir, connectorYamlPath),
235-
sdkInfo.connectorYamlContents,
236-
);
237-
}
229+
await config.askWriteProjectFile(
230+
path.relative(config.projectDir, connectorYamlPath),
231+
sdkInfo.connectorYamlContents,
232+
);
238233

239234
const account = getGlobalDefaultAccount();
240235
await DataConnectEmulator.generate({

0 commit comments

Comments
 (0)