Insert Command Line in typescript

1

I have a MongoDB installation and configuration script as needed by the company.

Install_MongoDB.BAT

But I would like to automate this process by including in the project in TypeScript. I would like to insert commands that I created in .bat and include in a Project already completed and then Generate an Executable with Electron.

How could I enter the CMD commands within TypeScript? What would be the best way?

    
asked by anonymous 04.12.2018 / 22:15

1 answer

1

To execute a command on the terminal using TypeScript, you can use the exec function of the native library of% Node child_process . With it, you can do:

import { exec } from 'child_process'

exec("mkdir test", (err, stdout, stderr) => {
    if (err) {
        // Caso o Node não consiga efetuar o comando
        return console.error(err)
    }
    // Resultado do programa
    console.log('stdout: ${stdout}')
    // Caso o node execute mas o comando encontre algum erro
    console.log('stderr: ${stderr}')
})

This code will execute the command on the terminal mkdir test creating the directory test if all goes well. You can adapt the code to meet your needs with Electron. It is worth mentioning that this code must be run in main of Electron, which is the one that has access to the Node library. From there, you can use the events, for through the client to call the code in the "backend".

    
04.12.2018 / 22:28
___ ___ erkimt Unable to build entity manager factory (JPA Hibernate) ______ qstntxt ___

I am trying to make a connection with Hibernate and JPA, but when trying to create the connection or persist some data it executes the following error:

  

Dec 04, 2018 2:02:45 PM org.hibernate.ejb.HibernatePersistence   WARN: logDeprecation HHH015016: Encountered to deprecated   javax.persistence.spi.PersistenceProvider   [org.hibernate.ejb.HibernatePersistence]; use   [org.hibernate.jpa.HibernatePersistenceProvider] instead. Dec 04, 2018   2:02:45 PM org.hibernate.ejb.HibernatePersistence logDeprecation WARN:   HHH015016: Encountered to deprecated   javax.persistence.spi.PersistenceProvider   [org.hibernate.ejb.HibernatePersistence]; use   [org.hibernate.jpa.HibernatePersistenceProvider] instead. Dec 04, 2018   2:02:45 PM org.hibernate.ejb.HibernatePersistence logDeprecation WARN:   HHH015016: Encountered to deprecated   javax.persistence.spi.PersistenceProvider   [org.hibernate.ejb.HibernatePersistence]; use   [org.hibernate.jpa.HibernatePersistenceProvider] instead. Dec 04, 2018   2:02:45 PM org.hibernate.jpa.internal.util.LogHelper   INFO: HHH000204: LogPersistenceUnitInformation   PersistenceUnitInfo [name: context ...] Dec 04, 2018 2:02:45 PM   INFO: HHH000412: hibernate Core   {4.3.0.Final} Dec 04, 2018 2:02:45 PM org.hibernate.cfg.Environment    INFO: HHH000206: hibernate.properties not found Dec 04, 2018   INFO: 2:02:45 PM org.hibernate.cfg.Environment buildBytecodeProvider   HHH000021: Bytecode provider name: javassist Dec 04, 2018 2:02:45 PM   org.hibernate.annotations.common.reflection.java.JavaReflectionManager    INFO: HCANN000001: Hibernate Commons Annotations   {4.0.4.Final} Dec 04, 2018 2:02:45 PM   org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl   configure INFO: HHH000402: Using Hibernate built-in connection pool   (not for production use!) Unable to build entity manager factory

My pom.xml

%pre%

My persistence.xml

%pre%

My Main class

%pre%     
______ azszpr348573 ___

Black screen in android emulator