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

stop all spinner in child process #180

Open
pincman opened this issue Jun 28, 2021 · 0 comments
Open

stop all spinner in child process #180

pincman opened this issue Jun 28, 2021 · 0 comments

Comments

@pincman
Copy link

pincman commented Jun 28, 2021

I run a nestjs server in nodemon,like follow

const runner = nodemon({
        script: 'src/main.ts',
        ext: 'js,json,ts',
        watch: ['src'],
        ignore: ['.git', 'node_modules', 'dist', 'scripts'],
        execMap: {
            ts: 'eslint "{src,apps,libs,test}/**/*.ts" --fix && node -r @swc/register -r module-alias/register',
        },
        env: {
            NODE_ENV: environment(),
        },
        cwd: path.resolve(__dirname, '..', '..'),
        spawn: true,
    });
    runner.once(
        'start',
        () => {
            ora('Server is in starting...').start();
        },
    );

and in child process
main.ts

await app.listen(appConfig.port, appConfig.host, () => {
        console.log();
        console.log('Server has started:');
        const listens: string[] = [];
        const nets = networkInterfaces();
       // in here stop all ora spinner,ora().clear() not work

        Object.entries(nets).forEach(([_, net]) => {
            if (net) {
                for (const item of net) {
                    if (item.family === 'IPv4') listens.push(item.address);
                }
            }
        });
        const urls = listens.map(
            (l) =>
                `${appConfig.https ? 'https' : 'http'}://${l}:${
                    appConfig.port
                }`,
        );
        if (urls.length > 0) {
            console.log(`- Local: ${chalk.green.underline(urls[0])}`);
        }
        if (urls.length > 1) {
            console.log(`- Network: ${chalk.green.underline(urls[1])}`);
        }
    });

and I want to stop ora spinner after server started

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant