Last active
February 8, 2021 06:18
-
-
Save olange/a12e72efe58b8199d27a3e1234ea830f to your computer and use it in GitHub Desktop.
List of executables available in Firebase Cloud Functions Node.js runtime
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
/** | |
* 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
Nice, next to ImageMagick and many utilities to work with the PBM image format, Ghostscript is also available on the command-line to process PDF and PS documents. Although not explicitely listed in Google Cloud Node.js runtime image, it probably comes from the base Ubuntu 16.04 image.