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

preserve the full --inspect= flag as passed to yarn start #660

Merged
merged 2 commits into from
Jun 18, 2018
Merged
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
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ You can again view your application at `http://localhost:3000`
Runs the test watcher (Jest) in an interactive mode.
By default, runs tests related to files changed since the last commit.

### `npm start -- --inspect` or `yarn start -- --inspect`
### `npm start -- --inspect=[host:port]` or `yarn start -- --inspect=[host:port]`

To debug the node server, you can use `razzle start --inspect`. This will start the node server and enable the inspector agent. For more information, see [this](https://nodejs.org/en/docs/guides/debugging-getting-started/).
To debug the node server, you can use `razzle start --inspect`. This will start the node server and enable the inspector agent. The `=[host:port]` is optional and defaults to `=127.0.0.1:9229`. For more information, see [this](https://nodejs.org/en/docs/guides/debugging-getting-started/).

### `npm start -- --inspect-brk` or `yarn start -- --inspect-brk`
### `npm start -- --inspect-brk=[host:port]` or `yarn start -- --inspect-brk=[host:port]`

To debug the node server, you can use `razzle start --inspect-brk`. This will start the node server, enable the inspector agent and Break before user code starts. For more information, see [this](https://nodejs.org/en/docs/guides/debugging-getting-started/).
This is the same as --inspect, but will also break before user code starts. (to give a debugger time to attach before early code runs) For more information, see [this](https://nodejs.org/en/docs/guides/debugging-getting-started/).

### `rs`

Expand Down
10 changes: 5 additions & 5 deletions packages/razzle/config/createConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,11 +326,11 @@ module.exports = (

const nodeArgs = ['-r', 'source-map-support/register'];

// Add --inspect or --inspect-brk flag when enabled
if (process.env.INSPECT_BRK_ENABLED) {
nodeArgs.push('--inspect-brk');
} else if (process.env.INSPECT_ENABLED) {
nodeArgs.push('--inspect');
// Passthrough --inspect and --inspect-brk flags (with optional [host:port] value) to node
if (process.env.INSPECT_BRK) {
nodeArgs.push(process.env.INSPECT_BRK);
} else if (process.env.INSPECT) {
nodeArgs.push(process.env.INSPECT);
}

config.plugins = [
Expand Down
11 changes: 6 additions & 5 deletions packages/razzle/scripts/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ const setPorts = require('razzle-dev-utils/setPorts');

process.noDeprecation = true; // turns off that loadQuery clutter.

if (process.argv.includes('--inspect-brk')) {
process.env.INSPECT_BRK_ENABLED = true;
} else if (process.argv.includes('--inspect')) {
process.env.INSPECT_ENABLED = true;
}
// Capture any --inspect or --inspect-brk flags (with optional values) so that we
// can pass them when we invoke nodejs
process.env.INSPECT_BRK =
process.argv.find(arg => arg.match(/--inspect-brk(=|$)/)) || '';
process.env.INSPECT =
process.argv.find(arg => arg.match(/--inspect(=|$)/)) || '';

function main() {
// Optimistically, we make the console look exactly like the output of our
Expand Down