Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@
"strings": "on",
"other": "on"
},
"editor.suggestOnTriggerCharacters": true
"editor.suggestOnTriggerCharacters": true,
"[typescript]": {
"editor.defaultFormatter": "vscode.typescript-language-features"
}
}
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,4 @@
"prettier": "^2.1.2",
"typescript": "^4.3.2"
}
}
}
2 changes: 1 addition & 1 deletion src/cli/unknown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const handleUnknownArgs = (): void => {
if (!(flags.length === 1 && (flags[0] === '--help' || flags[0] === '-h'))) {
const message = `${flags.join(
', '
)} does not exists as a valid command.`;
)} does not exist as a valid command.`;
warn(message);
}

Expand Down
2 changes: 1 addition & 1 deletion src/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Options
-l --logout nothing Accepts boolean value: use it in order to expire your current session.
-r --listPlans nothing Accepts boolean value: list all the plans that are offered in your account using it.
-u --serverUrl string Change the base URL for the FaaS.
-c --confDir string (TODO) Overwrite the default configuration directory.`;
-c --confDir string Overwrite the default configuration directory.`;

export const printHelp = (): void => {
console.log(helpText);
Expand Down
4 changes: 3 additions & 1 deletion src/test/cli.integration.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/* eslint-disable prettier/prettier */

import { fail, notStrictEqual, ok, strictEqual } from 'assert';
import { join } from 'path';
import { load } from '../config';
Expand Down Expand Up @@ -93,7 +95,7 @@ describe('Integration CLI (Deploy)', function () {
);
} catch (err) {
ok(
String(err) === '! --yeet does not exists as a valid command.\n'
String(err) === '! --yeet does not exist as a valid command.\n'
);
}
});
Expand Down
41 changes: 41 additions & 0 deletions src/test/confDir.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { strictEqual } from 'assert';
import { existsSync, mkdirSync, rmdirSync, writeFileSync } from 'fs';
import { join } from 'path';
import { startup } from '../startup';

describe('Configuration Directory Logic', () => {
// 1. Create a temporary folder path
const customPath = join(process.cwd(), 'test-custom-config');
const configFilePath = join(customPath, 'config.ini');

const fakeToken = 'test-token-12345';

// Write in INI format (key=value)
const iniContent = `token=${fakeToken}`;

before(() => {
if (!existsSync(customPath)) {
mkdirSync(customPath);
}
// Write the INI file
writeFileSync(configFilePath, iniContent, 'utf8');
});

after(() => {
if (existsSync(customPath)) {
// Cleanup
rmdirSync(customPath, { recursive: true });
}
});

it('should load config from a custom directory via --confDir', async () => {
// Run startup. It should find config.ini and use the token inside.
const config = await startup(customPath);

strictEqual(
config.token,
fakeToken,
'The token loaded does not match the custom config file'
);
});
});