Skip to content

Commit 1ce3805

Browse files
Itai GendlerItai Gendler
authored andcommitted
Replace log printing library from log-udpate to draftlog to fix awk usage
1 parent c99925d commit 1ce3805

File tree

3 files changed

+29
-31
lines changed

3 files changed

+29
-31
lines changed

lib/interface/cli/helpers/get.js

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,18 @@
22
const _ = require('lodash');
33
const columnify = require('columnify');
44
const yaml = require('js-yaml');
5-
const logUpdate = require('log-update');
5+
const draftlog = require('draftlog');
6+
7+
draftlog.into(console);
8+
9+
let update;
10+
const print = (output) => {
11+
if (update) {
12+
update(output);
13+
} else {
14+
update = console.draft(output);
15+
}
16+
};
617

718
//i tried that this function will be dynamic (with the keys). it is also possible to add an array with all the fields if you think it better
819
const _printArrayTable = (data) => {
@@ -20,7 +31,7 @@ const _printArrayTable = (data) => {
2031
res.push(obj);
2132
});
2233
const columns = columnify(res);
23-
logUpdate(columns);
34+
print(columns);
2435
};
2536

2637
const _printSingleTable = (info) => {
@@ -32,21 +43,20 @@ const _printSingleTable = (info) => {
3243
});
3344
res.push(obj);
3445
const columns = columnify(res);
35-
logUpdate(columns);
46+
print(columns);
3647
};
3748

3849

3950
const specifyOutputForSingle = (type, enitity) => {
40-
logUpdate.clear();
4151
switch (type) {
4252
case 'json':
43-
logUpdate(enitity.toJson());
53+
print(enitity.toJson());
4454
break;
4555
case 'yaml':
46-
logUpdate(enitity.toYaml());
56+
print(enitity.toYaml());
4757
break;
4858
case 'name':
49-
logUpdate(enitity.toName());
59+
print(enitity.toName());
5060
break;
5161
case 'wide':
5262
_printSingleTable(enitity.toWide());
@@ -58,7 +68,6 @@ const specifyOutputForSingle = (type, enitity) => {
5868

5969

6070
const specifyOutputForArray = (type, enitities) => {
61-
logUpdate.clear();
6271
switch (type) {
6372
case 'json':
6473
const jsonArray = [];
@@ -67,9 +76,9 @@ const specifyOutputForArray = (type, enitities) => {
6776
});
6877

6978
if (jsonArray.length === 1) {
70-
logUpdate(JSON.stringify(jsonArray[0], null, '\t'));
79+
print(JSON.stringify(jsonArray[0], null, '\t'));
7180
} else {
72-
logUpdate(JSON.stringify(jsonArray, null, '\t'));
81+
print(JSON.stringify(jsonArray, null, '\t'));
7382
}
7483

7584
break;
@@ -82,14 +91,14 @@ const specifyOutputForArray = (type, enitities) => {
8291
});
8392

8493
if (yamlArray.items.length === 1) {
85-
logUpdate(yaml.safeDump(yamlArray.items[0]));
94+
print(yaml.safeDump(yamlArray.items[0]));
8695
} else {
87-
logUpdate(yaml.safeDump(yamlArray));
96+
print(yaml.safeDump(yamlArray));
8897
}
8998
break;
9099
case 'name':
91100
_.forEach(enitities, (entity) => {
92-
logUpdate(entity.toName());
101+
print(entity.toName());
93102
});
94103
break;
95104
case 'wide':

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codefresh",
3-
"version": "0.8.5",
3+
"version": "0.8.6",
44
"description": "Codefresh command line utility",
55
"main": "index.js",
66
"preferGlobal": true,
@@ -33,13 +33,13 @@
3333
"columnify": "^1.5.4",
3434
"copy-dir": "^0.3.0",
3535
"debug": "^3.1.0",
36+
"draftlog": "^1.0.12",
3637
"filesize": "^3.5.11",
3738
"firebase": "git+https://github.com/codefresh-io/firebase.git#80b2ed883ff281cd67b53bd0f6a0bbd6f330fed5",
3839
"js-yaml": "^3.10.0",
3940
"jsonwebtoken": "^8.1.0",
4041
"kefir": "^3.8.0",
4142
"lodash": "^4.17.4",
42-
"log-update": "^2.3.0",
4343
"mkdirp": "^0.5.1",
4444
"moment": "^2.19.4",
4545
"mongodb": "^3.0.1",

yarn.lock

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@ cli-cursor@^1.0.1:
665665
dependencies:
666666
restore-cursor "^1.0.1"
667667

668-
cli-cursor@^2.0.0, cli-cursor@^2.1.0:
668+
cli-cursor@^2.1.0:
669669
version "2.1.0"
670670
resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-2.1.0.tgz#b35dac376479facc3e94747d41d0d0f5238ffcb5"
671671
dependencies:
@@ -1037,6 +1037,10 @@ dot-prop@^3.0.0:
10371037
dependencies:
10381038
is-obj "^1.0.0"
10391039

1040+
draftlog@^1.0.12:
1041+
version "1.0.12"
1042+
resolved "https://registry.yarnpkg.com/draftlog/-/draftlog-1.0.12.tgz#7db6a3c5b62106bb32dd4a35d67bcccb6c7d9da0"
1043+
10401044
duplexer2@^0.1.4:
10411045
version "0.1.4"
10421046
resolved "https://registry.yarnpkg.com/duplexer2/-/duplexer2-0.1.4.tgz#8b12dab878c0d69e3e7891051662a32fc6bddcc1"
@@ -2625,14 +2629,6 @@ lodash@^4.13.1, lodash@^4.14.0, lodash@^4.17.4, lodash@^4.3.0:
26252629
version "4.17.4"
26262630
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae"
26272631

2628-
log-update@^2.3.0:
2629-
version "2.3.0"
2630-
resolved "https://registry.yarnpkg.com/log-update/-/log-update-2.3.0.tgz#88328fd7d1ce7938b29283746f0b1bc126b24708"
2631-
dependencies:
2632-
ansi-escapes "^3.0.0"
2633-
cli-cursor "^2.0.0"
2634-
wrap-ansi "^3.0.1"
2635-
26362632
longest@^1.0.1:
26372633
version "1.0.1"
26382634
resolved "https://registry.yarnpkg.com/longest/-/longest-1.0.1.tgz#30a0b2da38f73770e8294a0d22e6625ed77d0097"
@@ -4222,13 +4218,6 @@ wrap-ansi@^2.0.0:
42224218
string-width "^1.0.1"
42234219
strip-ansi "^3.0.1"
42244220

4225-
wrap-ansi@^3.0.1:
4226-
version "3.0.1"
4227-
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-3.0.1.tgz#288a04d87eda5c286e060dfe8f135ce8d007f8ba"
4228-
dependencies:
4229-
string-width "^2.1.1"
4230-
strip-ansi "^4.0.0"
4231-
42324221
wrappy@1:
42334222
version "1.0.2"
42344223
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"

0 commit comments

Comments
 (0)