Skip to content

Commit 2abda35

Browse files
committed
chore: revert to local -> global config
1 parent dff3d17 commit 2abda35

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

src/commands/force/org/beta/create.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -269,14 +269,15 @@ export class Create extends SfdxCommand {
269269
this.logger.debug('Set Alias: %s result: %s', this.flags.setalias, result);
270270
}
271271
if (this.flags.setdefaultusername) {
272+
let config: Config;
272273
try {
273-
const config = await Config.create({ isGlobal: false });
274-
const result = config.set(Config.DEFAULT_USERNAME, username);
275-
await config.write();
276-
this.logger.debug('Set defaultUsername: %s result: %s', this.flags.setdefaultusername, result);
277-
} catch (error) {
278-
this.logger.debug('Set defaultUsername failed with error: %s', error);
274+
config = await Config.create({ isGlobal: false });
275+
} catch {
276+
config = await Config.create({ isGlobal: true });
279277
}
278+
const result = config.set(Config.DEFAULT_USERNAME, username);
279+
await config.write();
280+
this.logger.debug('Set defaultUsername: %s result: %s', this.flags.setdefaultusername, result);
280281
}
281282
}
282283
private async createScratchOrg(): Promise<ScratchOrgProcessObject> {

test/commands/force/org/scratchOrgCreate.test.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -199,12 +199,7 @@ describe('org:create', () => {
199199
username: 'newScratchUsername',
200200
});
201201
const aliasStub = stubMethod(sandbox, Aliases.prototype, 'set');
202-
const setStub = sandbox.spy();
203-
const writeStub = sandbox.spy();
204-
const configCreateStub = stubMethod(sandbox, Config, 'create').withArgs({ isGlobal: false }).resolves({
205-
set: setStub,
206-
write: writeStub,
207-
});
202+
const configStub = stubMethod(sandbox, Config.prototype, 'set');
208203
await command.runIt();
209204
expect(prodOrg.firstCall.args[0]).to.deep.equal({
210205
apiversion: undefined,
@@ -222,10 +217,7 @@ describe('org:create', () => {
222217
orgConfig: {},
223218
});
224219
expect(aliasStub.firstCall.args).to.deep.equal(['sandboxAlias', 'newScratchUsername']);
225-
expect(configCreateStub.calledOnce).to.be.true;
226-
expect(writeStub.calledOnce).to.be.true;
227-
expect(configCreateStub.firstCall.firstArg).to.deep.equal({ isGlobal: false });
228-
expect(setStub.firstCall.args).to.deep.equal(['defaultusername', 'newScratchUsername']);
220+
expect(configStub.firstCall.args).to.deep.equal(['defaultusername', 'newScratchUsername']);
229221
});
230222

231223
it('will test json output', async () => {

0 commit comments

Comments
 (0)