Forked from olange/google-firebase-functions-list-available-executables.js
Created
February 8, 2021 06:18
-
-
Save NeverwinterMoon/72af419ba5a6573a7035341a3dbafc7e to your computer and use it in GitHub Desktop.
List of executables available in Firebase Cloud Functions Node.js runtime
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
/** | |
* List of executables in Cloud Functions runtime. | |
* Invoke with https://us-central1-‹project-name›.cloudfunctions.net/ls | |
*/ | |
const functions = require( "firebase-functions"); | |
const spawn = require( "child-process-promise").spawn; | |
const ls = (req, res) => { | |
console.log( "Listing contents of /usr/[local/][s]bin"); | |
return spawn( "ls", | |
[ "-1F", "/usr/local/bin", "/usr/local/sbin", "/usr/bin", "/usr/sbin" ], | |
{ capture: [ "stdout", "stderr"] }) | |
.then(( result) => { | |
console.log( "List of files", result.stdout); | |
return res.status( 200) | |
.send( `List of files: ${result.stdout.split("\n").join("<br/>")}`); | |
}) | |
.catch(( err) => { | |
console.error( `ls error: ${err.stderr}`) | |
throw err; | |
}); | |
}; | |
exports.ls = functions.https.onRequest( ls); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment