1 | const getStream = require("get-stream");
|
2 | const chalk = require("chalk");
|
3 | // const notifier = require("node-notifier");
|
4 |
|
5 | // custom simple logger
|
6 | // use it like console
|
7 | const execa = require("execa");
|
8 | const exec = async command => {
|
9 | let output;
|
10 |
|
11 | try {
|
12 | // console.log("Starting to run: ");
|
13 | console.log(`${chalk.green.bold("Running: ")}: ${chalk.underline(command)}`);
|
14 | output = execa.shell(command, { env: { FORCE_COLOR: true } }).stdout; //.pipe(process.stdout);
|
15 |
|
16 | // getStream(output).then(() => {
|
17 | // notifier.notify({
|
18 | // title: "Something went wrong when trying to run " + command,
|
19 | // message: "OOOPS"
|
20 | // });
|
21 | // process.exit();
|
22 | // });
|
23 | // console.log(output);
|
24 | } catch (error) {
|
25 | // console.log(`${chalk.red.bold(error)}`);
|
26 | //
|
27 | }
|
28 | output.pipe(process.stdout);
|
29 | return output;
|
30 | };
|
31 |
|
32 | module.exports = async ({ script }) => {
|
33 | return await exec(script.src + process.argv.slice(2));
|
34 | };
|
35 | //
|
36 | // // const notifier = require("node-notifier");
|
37 | // const util = require('util');
|
38 | //
|
39 | // // async function main() {
|
40 | // //
|
41 | // // }
|
42 | //
|
43 | // // custom simple logger
|
44 | // // use it like console
|
45 | const execa = require("execa");
|
46 | const exec = async command => {
|
47 | let output;
|
48 |
|
49 | try {
|
50 | output = execa.shell(command, { env: { FORCE_COLOR: true } }).stdout;
|
51 |
|
52 | getStream(output).then(() => {
|
53 | // notifier.notify({
|
54 | // title: "Something went wrong when trying to run " + command,
|
55 | // message: "OOOPS"
|
56 | // });
|
57 | process.exit();
|
58 | });
|
59 | // console.log(output);
|
60 | } catch (error) {
|
61 | // console.log(`${chalk.red.bold(error)}`);
|
62 | //
|
63 | }
|
64 | output.pipe(process.stdout);
|
65 | return output;
|
66 | };
|
67 | //
|
68 | // module.exports = async ({ script }) => {
|
69 | // const exec = util.promisify(require('child_process').exec);
|
70 | //
|
71 | // // return console.log("ASIDJASODOISADIOJSAD");
|
72 | // // const spawn = require("child_process").spawn;
|
73 | //
|
74 | // const { stdout, stderr } = await exec(script.src+ process.argv.slice(2));
|
75 | //
|
76 | // if (stderr) {
|
77 | // console.error(`error: ${stderr}`);
|
78 | // }
|
79 | // console.log(`Number of files ${stdout}`);
|
80 | // // return await spawn(script.src+ process.argv.slice(2), { stdio: "inherit", env: process.env });
|
81 | // };
|