Skip to content

Commit 45d91e5

Browse files
committed
fix: use data dir by default instead of cwd if populated for config file
1 parent 5e4d2d8 commit 45d91e5

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

src/adapters/base-class.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ export default class BaseClass {
394394
data.project = this.config.currentConfig;
395395
}
396396

397-
writeFileSync(`${this.config.projectBasePath}/${this.config.configName}`, JSON.stringify(data), {
397+
writeFileSync(this.config.configName, JSON.stringify(data), {
398398
encoding: 'utf8',
399399
flag: 'w',
400400
});

src/base-command.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export abstract class BaseCommand<T extends typeof Command> extends Command {
110110
this.exit(1);
111111
}
112112

113-
const configPath = this.flags.config || resolve(currentWorkingDirectory, config.configName);
113+
const configPath = this.flags.config || resolve(projectBasePath, config.configName);
114114

115115
let baseUrl = config.launchBaseUrl || this.launchHubUrl;
116116
if (!baseUrl) {

test/unit/base-command.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ describe('BaseCommand', () => {
133133
'data-dir': '/root/subdirectory/project1',
134134
};
135135
baseCommandInstance.flags = flags;
136+
existsSyncStub.withArgs('/root/subdirectory/project1/.cs-launch.json').returns(false);
136137

137138
await baseCommandInstance.prepareConfig();
138139

@@ -146,7 +147,7 @@ describe('BaseCommand', () => {
146147
host: 'host.contentstack.io',
147148
'data-dir': '/root/subdirectory/project1',
148149
projectBasePath: '/root/subdirectory/project1',
149-
config: '/root/.cs-launch.json',
150+
config: '/root/subdirectory/project1/.cs-launch.json',
150151
authtoken: 'testauthtoken',
151152
authType: 'testauthorisationType',
152153
authorization: 'testoauthAccessToken',

0 commit comments

Comments
 (0)