Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip adding protected devices to non-protection products #768

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading