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 14a0525..fbe748b 100644 --- a/src/test/cli.integration.spec.ts +++ b/src/test/cli.integration.spec.ts @@ -1,4 +1,5 @@ import { fail, notStrictEqual, ok, strictEqual } from 'assert'; +import { writeFile } from 'fs/promises'; import { join } from 'path'; import { load } from '../config'; import { @@ -74,6 +75,34 @@ describe('Integration CLI (Deploy)', function () { } }); + // --confDir + it('Should be able to login using --confDir flag', async function () { + const file = await load(); + const token = file.token || ''; + + notStrictEqual(token, ''); + + await clearCache(); + + const confDir = await createTmpDirectory(); + const configPath = join(confDir, 'config.ini'); + await writeFile(configPath, `token=${token}`, 'utf8'); + + const workdir = await createTmpDirectory(); + + try { + await runCLI( + [`--confDir=${confDir}`, `--workdir=${workdir}`], + [keys.enter, keys.enter] + ).promise; + } catch (err) { + strictEqual( + err, + `X The directory you specified (${workdir}) is empty.\n` + ); + } + }); + // --help it('Should be able to print help guide using --help flag', async () => { const result = await runCLI(['--help'], [keys.enter]).promise; @@ -92,9 +121,7 @@ describe('Integration CLI (Deploy)', function () { )}` ); } catch (err) { - ok( - String(err) === '! --yeet does not exist as a valid command.\n' - ); + ok(String(err) === '! --yeet does not exist as a valid command.\n'); } });