Created
September 30, 2015 02:09
-
-
Save richardsawyer/444419fcdd20d06f3c08 to your computer and use it in GitHub Desktop.
Gulp script for raygun
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* global Promise */ | |
var gulp = require('gulp'); | |
var paths = require('../config/gulp').paths; | |
var config = require('../config/environment'); | |
var request = require('request'); | |
var fs = require('fs'); | |
//generate map files in main build task with .pipe(gsourcemaps.write('map')) after min and concat | |
gulp.task('raygunApp', function () { | |
var uploads = []; | |
uploads.push(uploadToRaygun('map/app.js.map')); | |
uploads.push(uploadToRaygun('app.js')); | |
return Promise.all(uploads); | |
}); | |
gulp.task('raygunVendor', function(){ | |
var uploads = []; | |
uploads.push(uploadToRaygun('vendor.js')); | |
uploads.push(uploadToRaygun('map/vendor.js.map')); | |
return Promise.all(uploads); | |
}); | |
function uploadToRaygun(file) { | |
var raygun = 'https://app.raygun.io/upload/jssymbols/xxxx' + '?authToken=' + 'xxx-extAccessToken'; | |
var srcRoot = __dirname + '\\.' + paths.distJs; | |
var src = srcRoot + file; | |
var dest = file; | |
var formData = { | |
file: fs.createReadStream(src), | |
url: 'http://yoursite.com' + '/scripts/' + dest | |
}; | |
console.log('Uploading ' + file + ' mapped to ' + formData.url); | |
return new Promise(function (resolve, reject) { | |
request.post({ | |
// proxy: 'http://127.0.0.1:8888', //pipe to fiddler | |
url: raygun, | |
formData: formData | |
}, function (e, res) { | |
if (e) { | |
console.e .log('error: ' + e); | |
reject(e); | |
} | |
else { | |
resolve(res); | |
} | |
}); | |
}); | |
} | |
gulp.task('raygun', ['raygunApp', 'raygunVendor']); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment