Skip to content

Commit

Permalink
fix(config): properly set filename when running config init
Browse files Browse the repository at this point in the history
  • Loading branch information
JaredReisinger committed Jul 18, 2024
1 parent 98df4a8 commit d90c8f6
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ test('cli... runs the app?', async (t) => {
process.argv = ['', '', '--help'];
await t.notThrowsAsync(async () => {
const result = await import('./cli.js');
t.log(result);
// t.log(result);
t.truthy(result);
});
});
2 changes: 1 addition & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ async function loadConfig(): Promise<ConfigFile> {
// dbg(0, 'checking for config', { filename });
try {
const data = await readFileAsync(filename);
const cfg = JSON.parse(data.toString());
const cfg = JSON.parse(data.toString()) as ConfigFile;
cfg._filename = filename;
return cfg;
} catch (e) {
Expand Down
2 changes: 2 additions & 0 deletions src/commands/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ test('Config.init() should return a Promise', async (t) => {
test('Config.init() should write config from answers', async (t) => {
const configMissing = new Config(
{
_filename: 'CONFIG_FILE',
_missing: true,
hosts: {},
},
Expand Down Expand Up @@ -267,6 +268,7 @@ test('Config.init() should write config from answers', async (t) => {

t.is(write.callCount, 1);
t.deepEqual(write.getCall(0).firstArg, {
_filename: 'CONFIG_FILE',
hosts: {
NAME: {
key: 'MAGIC_KEY',
Expand Down
1 change: 1 addition & 0 deletions src/commands/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ hosts:${Object.entries(this.cfg.hosts)

const { name, url, key, secret } = host;
const cfg = {
_filename: this.cfg._filename,
timezone,
hosts: {
[name]: { url, key, secret },
Expand Down

0 comments on commit d90c8f6

Please sign in to comment.