Last active
February 24, 2018 04:06
-
-
Save chathurawidanage/423e0a2f2f5890f2b526db660c4453ae to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const { execSync } = require('child_process'); | |
const fs = require("fs"); | |
let read = fs.readFileSync('index.js'); //reading myself | |
let code = read.toString(); | |
let requireRegex = /=\s*require\s*\(['\"](.+)['\"]\)/g; | |
let match = requireRegex.exec(code); | |
while (match != null) { | |
let lib = match[1]; | |
match = requireRegex.exec(code); | |
if (lib === 'child_process' || lib === 'fs') { | |
continue; | |
} | |
execSync(`npm install --prefix /tmp --save ${lib}`); | |
} | |
let oldRequire = require; | |
require = function(module) { | |
return oldRequire(`/tmp/node_modules/${module}`); | |
} | |
/* JUST FORGET EVERYTHING AND START YOUR CODE FROM THIS POINT ONWARDS*/ | |
let reverseString = require('reverse-string'); | |
let mathjs = require('mathjs'); | |
exports.handler = (event, context, callback) => { | |
callback(null, reverseString(' = evitavired')+mathjs.derivative('x^2 + x', 'x')); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment