Created
January 26, 2023 05:55
-
-
Save ZackDeRose/8881e4bec7f127cd5bdd4ab889b19786 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ServeFullstackExecutorSchema } from './schema'; | |
import { ExecutorContext } from '@nrwl/devkit'; | |
import { ChildProcess, exec } from 'child_process'; | |
const LARGE_BUFFER = 1024 * 1000000; | |
export default async function runExecutor( | |
options: ServeFullstackExecutorSchema, | |
_context: ExecutorContext | |
) { | |
await startBackendServer(options); | |
} | |
async function startBackendServer(options: ServeFullstackExecutorSchema) { | |
return new Promise(() => { | |
const childProcess = exec(`npx nx serve ${options.backendProject}`, { | |
maxBuffer: LARGE_BUFFER, | |
}); | |
process.on('exit', () => childProcess.kill()); | |
process.on('SIGTERM', () => childProcess.kill()); | |
childProcess.stdout.on('data', (data) => { | |
if (data.includes('build succeeded, watching for changes...')) { | |
// later we'll start our frontend serve here! | |
} | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment