Skip to content

Commit

Permalink
Skip adding protected devices to non-protection products
Browse files Browse the repository at this point in the history
  • Loading branch information
keeramis committed Sep 3, 2024
1 parent e179442 commit 4f9e7b4
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/cmd/product.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ module.exports = class ProductCommand extends CLICommandBase {
.then(result => this.showDeviceAddResult(result));
}

showDeviceAddResult({ product, identifiers, status: { invalidDeviceIds = [], nonmemberDeviceIds = [] } } = {}){
identifiers = filterDeviceIdentifiers(identifiers, invalidDeviceIds, nonmemberDeviceIds);
showDeviceAddResult({ product, identifiers, status: { invalidDeviceIds = [], nonmemberDeviceIds = [], protectedDeviceIds = [] } } = {}){
identifiers = filterDeviceIdentifiers(identifiers, invalidDeviceIds, nonmemberDeviceIds, protectedDeviceIds);
const message = [];

if (identifiers.length){
Expand Down Expand Up @@ -75,6 +75,14 @@ module.exports = class ProductCommand extends CLICommandBase {
);
}

if (protectedDeviceIds.length){
message.push(
'Skipped Protected IDs:',
dedupeAndStringifyIDList(protectedDeviceIds),
''
);
}

if (!identifiers.length){
throw new Error(message.join(os.EOL));
}
Expand Down Expand Up @@ -200,9 +208,10 @@ function readDeviceListFile(file){
});
}

function filterDeviceIdentifiers(identifiers, invalid = [], nonmember = []){
function filterDeviceIdentifiers(identifiers, invalid = [], nonmember = [], protectedDevice = []){
return identifiers.reduce((out, x) => {
if (!hasDeviceIdentifier(x, invalid) && !hasDeviceIdentifier(x, nonmember)){
if (!hasDeviceIdentifier(x, invalid) && !hasDeviceIdentifier(x, nonmember)
&& !hasDeviceIdentifier(x, protectedDevice)){
out.push(x);
}
return out;
Expand Down

0 comments on commit 4f9e7b4

Please sign in to comment.