Skip to content

Instantly share code, notes, and snippets.

@jaimeiniesta
Last active April 18, 2018 21:37
Show Gist options
  • Save jaimeiniesta/af5914adf0240701619d1fd077fd5b2f to your computer and use it in GitHub Desktop.
Save jaimeiniesta/af5914adf0240701619d1fd077fd5b2f to your computer and use it in GitHub Desktop.
Google Cloud Functions for AccessLint
/**
* HTTP Cloud Function.
*
* @param {Object} req Cloud Function request context.
* @param {Object} res Cloud Function response context.
*/
exports.accessLintJson = function accessLintJson (req, res) {
var url = req.param("url");
var exec = require('child_process').exec;
var cmd = `${__dirname}/node_modules/accesslint-cli/bin/accesslint --format=json ${url}`;
// https://github.com/SaschaGalley/grunt-phpunit/issues/29
// default buffer is 200 * 1024, so we set up a higher limit for the JSON output
exec(cmd, { maxBuffer: 10000 * 1024 }, function(error, stdout, stderr) {
if (error) {
console.log(error);
res.send(error);
}
console.log(stdout);
res.send(stdout);
});
};
{
"dependencies": {
"accesslint-cli": "git://github.com/jaimeiniesta/accesslint-cli.js.git#format-json"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment