Created
May 19, 2018 23:31
-
-
Save DaaGER/05cc9802e1bb9ae6fdb36c03bbf6378c to your computer and use it in GitHub Desktop.
Обход ссылок, поиск на них JS-ошибок и сигнализирование об этом в Slack
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
//В phpdoc контроллера указать @url | |
gulp.task('urlfind', function () { | |
return gulp.src('modules/*.class.php') | |
.pipe(find(/@url.(.+)+/g)) | |
.pipe(replace('@url ', '\r\n')) | |
.pipe(concat('urls.txt', {newLine: ''})) | |
.pipe(replace('\r\n\r\n', '')) | |
.pipe(replace(',', '')) | |
.pipe(gulp.dest('')); | |
}) |
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
/** | |
* Created by daager on 10.10.16. | |
* require Nightmare.js | |
*/ | |
fs = require('fs'); | |
var urls = fs.readFileSync('urls.txt', 'utf-8').split('\r\n'); | |
var Nightmare = require('nightmare'); | |
var IncomingWebhooks = require('@slack/client').IncomingWebhook; | |
var url_hook = 'https://hooks.slack.com/services/*********/*********/**************************'; | |
var wh = new IncomingWebhooks(url_hook); | |
function asd(url) { | |
if (url == '') { | |
if (urls.length > 0) { | |
asd(urls.shift()) | |
} | |
return; | |
} | |
var result = ''; | |
Nightmare({ | |
show: false, | |
width: 1600, | |
height: 800 | |
}) | |
.on('page', function (type, message, stack) { | |
console.log(stack) | |
result = result + stack; | |
}) | |
.goto(url) | |
.end() | |
.then(function () { | |
console.log('url_test: ' + url); | |
if (result.length > 0) { | |
wh.send({ | |
text: result + url, | |
channel: 'js_error', | |
icon_emoji: ':scream:', | |
username: 'url_test.js' | |
}); | |
console.log(result); | |
console.log(''); | |
} | |
if (urls.length > 0) { | |
asd(urls.shift()) | |
} | |
}); | |
} | |
asd(urls.shift()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment