Skip to content
This repository was archived by the owner on May 19, 2025. It is now read-only.

Commit a09b754

Browse files
Make changes in contenttype module for recursive deletion
1 parent a12f668 commit a09b754

File tree

2 files changed

+33
-16
lines changed

2 files changed

+33
-16
lines changed

app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ login(config).then(function() {
4040
return;
4141
}).catch(function(error) {
4242
log.error('Failed to ' + val);
43-
log.error(error);
43+
// log.error(error);
4444
return;
4545
})
4646
} else {

lib/delete/delete_contentTypes.js

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,17 @@ DeleteContentTypes.prototype = {
4646
log.success('All mentioned contentTypes deleted successfully');
4747
return resolve();
4848
}
49-
5049
}).catch(function (error) {
5150
// eslint-disable-next-line no-console
5251
return reject(error);
5352
});
5453
} else {
5554
return reject();
5655
}
57-
58-
console.log(answer);
59-
});
56+
}).catch(function (error) {
57+
// eslint-disable-next-line no-console
58+
return reject(error);
59+
});
6060
} else {
6161
const confirm = new Confirm('Are you sure, you want to delete All ContentTypes of'+" "+config.stack.name+" "+"stack")
6262
.run()
@@ -89,8 +89,12 @@ DeleteContentTypes.prototype = {
8989
log.success(contenttype+' '+ 'contenttype deleted successfully');
9090
}
9191
}).catch(function (error) {
92-
log.error(chalk.red(error.body.error));
93-
self.pending.push(contenttype);
92+
log.error(chalk.red(error.body.error_message));
93+
if(error.body.error_code === 117) {
94+
self.pending.push(contenttype);
95+
}
96+
return reject(error)
97+
9498
})
9599
},{
96100
concurrency: 1
@@ -111,9 +115,21 @@ DeleteContentTypes.prototype = {
111115
return self.deleteAllContentTypes(content_types).then(function () {
112116
if(self.pending && self.pending.length > 0) {
113117
self.pendingContentTypes().then(function() {
114-
log.success('Pending contentTypes deletion completed');
115118
return resolve();
116-
})
119+
// if(self.pending.length > 0) {
120+
// self.pendingContentTypes().then(function() {
121+
// log.success('Pending contentTypes deletion successfully!!!!');
122+
// console.log("ndcdncmdncdmcd")
123+
// })
124+
// } else {
125+
// log.success('Pending contentTypes deletion completed11111111');
126+
// return resolve();
127+
// }
128+
129+
}).catch(function (error) {
130+
// eslint-disable-next-line no-console
131+
return reject(error);
132+
});
117133
} else {
118134
return resolve();
119135
}
@@ -141,7 +157,7 @@ DeleteContentTypes.prototype = {
141157
log.success(contenttype.uid+' '+ 'contenttype deleted successfully');
142158
}
143159
}).catch(function (error) {
144-
log.error(chalk.red(error.body.error));
160+
log.error(chalk.red(error.body.error_message));
145161
self.pending.push(contenttype.uid);
146162
})
147163
},{
@@ -150,31 +166,32 @@ DeleteContentTypes.prototype = {
150166
return resolve();
151167
}).catch(function (error) {
152168
return reject();
153-
// console.log("errrorMapper", error);
154169
})
155170
})
156171
},
157172
pendingContentTypes: function() {
158173
var self = this;
159174
return new Promise(function (resolve, reject) {
160175
return Promise.map(self.pending, function (contenttype) {
161-
//var contenttypeUid = contenttype.uid;
162176
self.requestOptions['url'] = config.host + config.apis.content_types+contenttype
163177
self.requestOptions['method'] = 'DELETE'
178+
console.log("selddddddd", self)
164179
return request(self.requestOptions).then(function (response_data) {
165180
if(response_data.statusCode == 200) {
166-
log.success(contenttype+' '+ 'contenttype deleted successfully');
167-
}
181+
log.success("Referred "+ contenttype+' '+ 'contenttype deleted successfully');
182+
// var n = self.pending.indexOf(contenttype);
183+
// var y = self.pending.splice(n,1);
184+
}
185+
return resolve();
168186
}).catch(function (error) {
169-
log.error(error);
187+
return reject(error);
170188
})
171189
},{
172190
concurrency: 1
173191
}).then(function () {
174192
return resolve();
175193
}).catch(function (error) {
176194
return reject(error);
177-
// console.log("errrorMapper", error);
178195
})
179196
});
180197
}

0 commit comments

Comments
 (0)