Skip to content

Instantly share code, notes, and snippets.

@paulbatum
Created March 16, 2016 04:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulbatum/7f0927307f40a10aae85 to your computer and use it in GitHub Desktop.
Save paulbatum/7f0927307f40a10aae85 to your computer and use it in GitHub Desktop.
function to disable a function
var fs = require('fs');
var path = require('path');
module.exports = function (context, req) {
if (typeof req.query.name == 'undefined') {
context.res = {
status: 400,
body: "Please specify the name of the function to enable"
}
}
else {
var functionJsonPath = path.join(__dirname, '..', req.query.name, 'function.json');
var definition = JSON.parse(fs.readFileSync(functionJsonPath, {encoding: 'utf8'}));
definition.disabled = false;
fs.writeFileSync(functionJsonPath, JSON.stringify(definition));
context.res = {
// test
body: "Set function disabled status to: " + definition.disabled
}
}
context.done();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment