Created
March 16, 2016 04:20
-
-
Save paulbatum/7f0927307f40a10aae85 to your computer and use it in GitHub Desktop.
function to disable a function
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
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