build(analytics): allow build analytics to take previous exit code as the first argument

This commit is contained in:
Igor Minar 2016-03-03 21:56:39 -08:00 committed by Igor Minar
parent 10fedd0dfc
commit d9e78e4fa8
1 changed files with 10 additions and 0 deletions

View File

@ -1,5 +1,10 @@
#!/usr/bin/env node #!/usr/bin/env node
// Usage:
//
// build analytics start|success|error|<exitCode> <actionCategory> <actionName>
'use strict'; 'use strict';
@ -16,6 +21,11 @@ if (!analytics[actionCategory + 'Start']) {
throw new Error('Unknown build-analytics actionCategory "' + actionCategory + '"'); throw new Error('Unknown build-analytics actionCategory "' + actionCategory + '"');
} }
var exitCode = Number.parseInt(eventType, 10);
if (!Number.isNaN(exitCode)) {
eventType = (exitCode === 0) ? 'success' : 'error';
}
if (eventType != 'start' && eventType != 'success' && eventType != 'error') { if (eventType != 'start' && eventType != 'success' && eventType != 'error') {
throw new Error('Unknown build-analytics eventType "' + eventType + '"'); throw new Error('Unknown build-analytics eventType "' + eventType + '"');
} }