tiro-notes 0.27.1 → 0.27.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.js +30 -1
- package/cli.js~ +4 -0
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -1,4 +1,33 @@
|
|
|
1
1
|
function startTiroServerAsCli () {
|
|
2
|
-
console.log("
|
|
2
|
+
console.log("Starting Tiro-Notes from CLI...");
|
|
3
|
+
execCmd('node', ['./server/server.js'])
|
|
4
|
+
|
|
3
5
|
}
|
|
4
6
|
module.exports = startTiroServerAsCli;
|
|
7
|
+
|
|
8
|
+
/////////////////////
|
|
9
|
+
// SUPPORT FUNCTIONS
|
|
10
|
+
/////////////////////
|
|
11
|
+
|
|
12
|
+
// EXEC Function
|
|
13
|
+
const execCmd = (cmd, params, p) => {
|
|
14
|
+
console.log(`ExecCMD ${JSON.stringify({cmd, params, p})}`);
|
|
15
|
+
if (!p) p = {}
|
|
16
|
+
if (!p.env) p.env = {}
|
|
17
|
+
if (!p.onLog) p.onLog = () => {}
|
|
18
|
+
|
|
19
|
+
let spawn = require( 'child_process' ).spawn;
|
|
20
|
+
let child = spawn( cmd, params, {env: { ...process.env, ...p.env }});
|
|
21
|
+
|
|
22
|
+
child.stdout.on( 'data', data => {
|
|
23
|
+
const str = `[${cmd}] : ${data}`;
|
|
24
|
+
console.log( str );
|
|
25
|
+
});
|
|
26
|
+
child.stderr.on( 'data', data => {
|
|
27
|
+
const str = `[${cmd} ERROR!] : ${data}`;
|
|
28
|
+
console.log( str );
|
|
29
|
+
});
|
|
30
|
+
return child;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
package/cli.js~
ADDED