Skip to content

Commit

Permalink
feat(stores): adds the ability to list all stores
Browse files Browse the repository at this point in the history
  • Loading branch information
Ephigenia committed Aug 20, 2022
1 parent 79e70b3 commit 83a1a41
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Please report any bugs related to this alpha in the issues: https://github.com/E
Features
================================================================================

- list of 380 IKEA stores worldwide
- list of 395 IKEA stores worldwide
- get product stock amount for a whole country or single store in JSON, CSV and CLI-Table format including forecast (when available)
- support for many countries: at, au, be, ca, ch, cn, cz, de, dk, es, fi, fr, gb, hk, hr, hu, ie, it, jo, jp, kr, kw, lt, my, nl, no, pl, pt, qa, ro, ru, sa, se, sg, sk, th, tw, us
- integrate/use the library into your node project
Expand Down
21 changes: 17 additions & 4 deletions source/cli-stores.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ Examples:
get only the ids, the second column
ikea-availability-checker stores --plain de | awk '{print $2}'
get all stores
ikea-availability-checker stores
count all stores
ikea-availability-checker stores --plain | wc -l
get all store country codes, sorted asc
ikea-availability-checker stores --plain | awk '{print $1} | uniq | sort
`);
})
.action(function(countryCodes) {
Expand All @@ -46,10 +55,14 @@ Examples:
if (opts.plain) format = 'tsv';
if (opts.pretty) format = 'table';

const foundStores = [];
countryCodes.forEach(countryCode => {
stores.findByCountryCode(countryCode).forEach(store => foundStores.push(store));
});
let foundStores = [];
if (!countryCodes || !countryCodes.length) {
foundStores = stores.data;
} else {
countryCodes.forEach(countryCode => {
stores.findByCountryCode(countryCode).forEach(store => foundStores.push(store));
});
}

let report;
switch (format) {
Expand Down

0 comments on commit 83a1a41

Please sign in to comment.