Skip to content

Instantly share code, notes, and snippets.

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 NeverwinterMoon/72af419ba5a6573a7035341a3dbafc7e to your computer and use it in GitHub Desktop.
Save NeverwinterMoon/72af419ba5a6573a7035341a3dbafc7e to your computer and use it in GitHub Desktop.
List of executables available in Firebase Cloud Functions Node.js runtime
/**
* 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