Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save olange/a12e72efe58b8199d27a3e1234ea830f to your computer and use it in GitHub Desktop.
Save olange/a12e72efe58b8199d27a3e1234ea830f 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);
@olange
Copy link
Author

olange commented Aug 5, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment