Skip to content

Commit

Permalink
feat: Add port option to stencil start
Browse files Browse the repository at this point in the history
  • Loading branch information
onur-o7 committed Jan 2, 2025
1 parent 4fab613 commit ee21fa9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion bin/stencil-start.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ program
'-n, --no-cache',
'Turns off caching for API resource data per storefront page. The cache lasts for 5 minutes before automatically refreshing.',
)
.option('-t, --timeout', 'Set a timeout for the bundle operation. Default is 20 secs', '60');
.option('-t, --timeout', 'Set a timeout for the bundle operation. Default is 20 secs', '60')
.option('-p --port [portnumber]', 'Set port number to listen dev server');

const cliOptions = prepareCommand(program);
const options = {
open: cliOptions.open,
Expand All @@ -28,6 +30,7 @@ const options = {
apiHost: cliOptions.host,
tunnel: cliOptions.tunnel,
cache: cliOptions.cache,
port: cliOptions.port,
};
const timeout = cliOptions.timeout * 1000; // seconds
const buildConfigManager = new BuildConfigManager({ timeout });
Expand Down
7 changes: 7 additions & 0 deletions lib/stencil-start.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,14 @@ class StencilStart {
if (cliOptions.variation) {
await this._themeConfigManager.setVariationByName(cliOptions.variation);
}

const initialStencilConfig = await this._stencilConfigManager.read();

// Override Port Number if Cli option Exsist
if (cliOptions.port) {
initialStencilConfig.port = cliOptions.port;
}

// Use initial (before updates) port for BrowserSync
const browserSyncPort = initialStencilConfig.port;
const channelUrl = await this.getChannelUrl(initialStencilConfig, cliOptions);
Expand Down

0 comments on commit ee21fa9

Please sign in to comment.