Skip to content

Commit 1e6a91c

Browse files
committed
Skip logging in, init and sdk initialization for 'functions' command as it would not be required if a user simply wants to run launch cloud functions locally or in a serverless environment
1 parent b1b5dd6 commit 1e6a91c

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/commands/launch/functions.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1-
import { FlagInput, Flags } from '@contentstack/cli-utilities';
2-
3-
import { BaseCommand } from '../../base-command';
1+
import { FlagInput } from '@contentstack/cli-utilities';
42
import Contentfly from '../../util/cloud-function';
3+
import { Flags, Command } from '@oclif/core';
54

6-
export default class Functions extends BaseCommand<typeof Functions> {
5+
export default class Functions extends Command {
76
static description = 'Serve cloud functions';
87

98
static examples = [
109
'$ csdx launch:functions',
1110
'$ csdx launch:functions --port=port',
1211
'$ csdx launch:functions --data-dir <path/of/current/working/dir>',
13-
'$ csdx launch:functions --config <path/to/launch/config/file>',
1412
'$ csdx launch:functions --data-dir <path/of/current/working/dir> -p "port number"',
15-
'$ csdx launch:functions --config <path/to/launch/config/file> --port=port',
1613
];
1714

1815
static flags: FlagInput = {
@@ -21,13 +18,17 @@ export default class Functions extends BaseCommand<typeof Functions> {
2118
default: '3000',
2219
description: 'Port number',
2320
}),
21+
'data-dir': Flags.string({
22+
char: 'd',
23+
description: 'Current working directory',
24+
}),
2425
};
2526

2627
async run(): Promise<void> {
27-
this.sharedConfig.config =
28-
this.flags['data-dir'] || this.flags.config
29-
? this.flags.config?.split(`${this.sharedConfig.configName}`)[0] || this.flags['data-dir']
30-
: process.cwd();
31-
await new Contentfly(this.sharedConfig.config as string).serveCloudFunctions(+this.flags.port);
28+
const { flags } = await this.parse(Functions);
29+
const currentWorkingDirectory = process.cwd();
30+
const projectBasePath = flags['data-dir'] || currentWorkingDirectory;
31+
32+
await new Contentfly(projectBasePath).serveCloudFunctions(+flags.port);
3233
}
3334
}

0 commit comments

Comments
 (0)