Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add port option to stencil start #1250

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can do instead

Suggested change
const browserSyncPort = initialStencilConfig.port;
const browserSyncPort = cliOptions.port || initialStencilConfig.port;

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then we need do change

const updatedStencilConfig = this.updateStencilConfig(
            { initialStencilConfig, port: browserSyncPort},
            storeInfoFromAPI,
);

const channelUrl = await this.getChannelUrl(initialStencilConfig, cliOptions);
Expand Down
Loading