diff --git a/.vscode/settings.json b/.vscode/settings.json index af451c9..f24c653 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -11,5 +11,8 @@ "strings": "on", "other": "on" }, - "editor.suggestOnTriggerCharacters": true + "editor.suggestOnTriggerCharacters": true, + "[typescript]": { + "editor.defaultFormatter": "vscode.typescript-language-features" + } } diff --git a/package-lock.json b/package-lock.json index 02928e6..3525bf7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8941,4 +8941,4 @@ "integrity": "sha512-UzIwO92D0dSFwIRyyqAfRXICITLjF0IP8tRbEK/un7adirMssWZx8xF/1hZNE7t61knWZ+lhEuUvxlu2MO8qqA==" } } -} \ No newline at end of file +} diff --git a/package.json b/package.json index 4b011ed..32c5ec4 100644 --- a/package.json +++ b/package.json @@ -128,4 +128,4 @@ "prettier": "^2.1.2", "typescript": "^4.3.2" } -} \ No newline at end of file +} diff --git a/src/cli/unknown.ts b/src/cli/unknown.ts index 6f468ba..668521e 100644 --- a/src/cli/unknown.ts +++ b/src/cli/unknown.ts @@ -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); } diff --git a/src/help.ts b/src/help.ts index e1b0775..a33dab1 100644 --- a/src/help.ts +++ b/src/help.ts @@ -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); diff --git a/src/test/cli.integration.spec.ts b/src/test/cli.integration.spec.ts index 6063f99..7775225 100644 --- a/src/test/cli.integration.spec.ts +++ b/src/test/cli.integration.spec.ts @@ -1,3 +1,5 @@ +/* eslint-disable prettier/prettier */ + import { fail, notStrictEqual, ok, strictEqual } from 'assert'; import { join } from 'path'; import { load } from '../config'; @@ -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' ); } }); diff --git a/src/test/confDir.spec.ts b/src/test/confDir.spec.ts new file mode 100644 index 0000000..38c8418 --- /dev/null +++ b/src/test/confDir.spec.ts @@ -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' + ); + }); +});