Skip to content

Commit

Permalink
feat(node): add runtimeArgs for execute builder
Browse files Browse the repository at this point in the history
 Closes #2215
  • Loading branch information
Cammisuli authored and vsavkin committed Feb 25, 2020
1 parent 1cc9dd6 commit f2c47cf
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 1 deletion.
6 changes: 6 additions & 0 deletions docs/angular/api-node/builders/execute.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ Type: `number`

The port to inspect the process on. Setting port to 0 will assign random free ports to all forked processes.

### runtimeArgs

Type: `array`

Extra args passed to the node process

### waitUntilTargets

Type: `array`
Expand Down
6 changes: 6 additions & 0 deletions docs/react/api-node/builders/execute.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ Type: `number`

The port to inspect the process on. Setting port to 0 will assign random free ports to all forked processes.

### runtimeArgs

Type: `array`

Extra args passed to the node process

### waitUntilTargets

Type: `array`
Expand Down
6 changes: 6 additions & 0 deletions docs/web/api-node/builders/execute.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ Type: `number`

The port to inspect the process on. Setting port to 0 will assign random free ports to all forked processes.

### runtimeArgs

Type: `array`

Extra args passed to the node process

### waitUntilTargets

Type: `array`
Expand Down
22 changes: 22 additions & 0 deletions packages/node/src/builders/execute/execute.impl.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ describe('NodeExecuteBuilder', () => {
testOptions = {
inspect: true,
args: [],
runtimeArgs: [],
buildTarget: 'nodeapp:build',
port: 9229,
waitUntilTargets: [],
Expand Down Expand Up @@ -156,6 +157,27 @@ describe('NodeExecuteBuilder', () => {
});
});

describe('--runtimeArgs', () => {
it('should add runtime args to the node process', async () => {
await nodeExecuteBuilderHandler(
{
...testOptions,
runtimeArgs: ['-r', 'node-register']
},
context
).toPromise();
expect(fork).toHaveBeenCalledWith('outfile.js', [], {
execArgv: [
'-r',
'source-map-support/register',
'-r',
'node-register',
'--inspect=localhost:9229'
]
});
});
});

it('should log errors from killing the process', async done => {
treeKill.mockImplementation((pid, signal, callback) => {
callback(new Error('Error Message'));
Expand Down
3 changes: 2 additions & 1 deletion packages/node/src/builders/execute/execute.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const enum InspectType {

export interface NodeExecuteBuilderOptions extends JsonObject {
inspect: boolean | InspectType;
runtimeArgs: string[];
args: string[];
waitUntilTargets: string[];
buildTarget: string;
Expand Down Expand Up @@ -77,7 +78,7 @@ function runProcess(event: NodeBuildEvent, options: NodeExecuteBuilderOptions) {
}

function getExecArgv(options: NodeExecuteBuilderOptions) {
const args = ['-r', 'source-map-support/register'];
const args = ['-r', 'source-map-support/register', ...options.runtimeArgs];

if (options.inspect === true) {
options.inspect = InspectType.Inspect;
Expand Down
8 changes: 8 additions & 0 deletions packages/node/src/builders/execute/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@
"description": "Ensures the app is starting with debugging",
"default": "inspect"
},
"runtimeArgs": {
"type": "array",
"description": "Extra args passed to the node process",
"default": [],
"items": {
"type": "string"
}
},
"args": {
"type": "array",
"description": "Extra args when starting the app",
Expand Down

0 comments on commit f2c47cf

Please sign in to comment.