Skip to content
This repository has been archived by the owner on Jun 8, 2021. It is now read-only.

Commit

Permalink
feat(server): accept nodeArgs to be passed to the node command line
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Sep 15, 2019
1 parent d86209b commit b45baee
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Commands/Build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default class Build extends BaseCommand {
return
}

const compiler = new Compiler(this, this.projectRoot, rcContents)
const compiler = new Compiler(this, this.projectRoot, rcContents, [])

/**
* Pushing `package.json` and lock file to `copyToBuild` array, so that later we can run `npm install`
Expand Down
10 changes: 9 additions & 1 deletion src/Commands/Serve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ export default class Serve extends BaseCommand {
@flags.boolean({ description: 'Watch for file changes' })
public dev: boolean

@flags.array({ description: 'Pass arguments to the node command' })
public nodeArgs: string[]

/**
* Reference to the project root. It always have to be
* the current working directory
Expand All @@ -39,7 +42,12 @@ export default class Serve extends BaseCommand {
return
}

const compiler = new Compiler(this, this.projectRoot, rcContents)
const compiler = new Compiler(
this,
this.projectRoot,
rcContents,
this.nodeArgs,
)

/**
* Watch or compile project
Expand Down
5 changes: 3 additions & 2 deletions src/Services/Compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export class Compiler {
private _command: BaseCommand,
private _projectRoot: string,
private _rcFile: RcFile,
private _nodeArgs: string[],
) {
const compilerPath = require.resolve('typescript/lib/typescript', { paths: [this._projectRoot] })

Expand Down Expand Up @@ -266,7 +267,7 @@ export class Compiler {
*/
if (startServer && !hasError) {
console.log(this._command.colors.bgGreen().black(' Starting server '))
new HttpServer(`${config.options.outDir}/server.js`, this._projectRoot).start()
new HttpServer(`${config.options.outDir}/server.js`, this._projectRoot, this._nodeArgs).start()
}
})

Expand Down Expand Up @@ -318,7 +319,7 @@ export class Compiler {
/**
* Reference to HTTP server
*/
const httpServer = new HttpServer(`${config.options.outDir}/server.js`, this._projectRoot)
const httpServer = new HttpServer(`${config.options.outDir}/server.js`, this._projectRoot, this._nodeArgs)

/**
* Step 1: Cleanup build directory
Expand Down
2 changes: 2 additions & 0 deletions src/Services/HttpServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export class HttpServer {
constructor (
private _sourceFile: string,
private _projectRoot: string,
private _nodeArgs: string[] = [],
) {}

get isConnected () {
Expand All @@ -39,6 +40,7 @@ export class HttpServer {
buffer: false,
cwd: this._projectRoot,
env: getChildProcessEnvVariables(this._projectRoot),
nodeOptions: this._nodeArgs,
})

/**
Expand Down

0 comments on commit b45baee

Please sign in to comment.