Skip to content

Commit

Permalink
Feat(libs/git): create the runner
Browse files Browse the repository at this point in the history
Create the runner function, it allow execute any shell command
  • Loading branch information
marck-dev committed Feb 21, 2022
0 parents commit 58e9a21
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
*.lock
*-lock.*
*.test.*
*.log
*-error.log
nwjs
29 changes: 29 additions & 0 deletions libs/runner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const {
exec
} = require('child_process');
const {
SimpleLogger
} = require('mk-simple-logger');

function runCMD(cmd) {
return new Promise(async (resolve, reject) => {
exec(cmd, (error, stdout, stderr) => {
const logger = new SimpleLogger('CMD Worker');
logger.info("Running command: {cmd}", {
cmd
});
if (error || stderr) {
const err = stderr.split('\n')[0];
logger.error("Command sterr: {err}", {
err
});
reject(err);
}
if (stdout) {
logger.info("Command done! ");
resolve(stdout);
}
})
})
}
module.exports = runCMD;
19 changes: 19 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "mk-git-flow",
"version": "0.0.1",
"main": "index.html",
"repository": "http://gitea.marck-devs.com/marck/MK-git-flow.git",
"author": "Marck C. Guzmán <marck@marck-devs.com>",
"license": "MIT",
"window": {
"icon": "assets/img/icon.png"
},
"scripts": {
"startW": "./nwjs/nw.exe ."
},
"dependencies": {
"commander": "^9.0.0",
"dotenv": "^14.2.0",
"mk-simple-logger": "^0.1.7"
}
}

0 comments on commit 58e9a21

Please sign in to comment.