Search code examples
google-apps-scriptmimegoogle-drive-api

Is it possible to read the contents of a Google Apps Script from another Script


I'm looking for a way to read the contents of the script.gs files within a standalone Google Apps Script. I can't find a suitable getAs() Mime format in the Docslist.File service that doesn't fail. The context of this is that I want to use the html service/content service to be able to embed public GAS source samples in Google Sites and elsewhere. (in much the same way as embedding Gist Samples). Any ideas?


Solution

  • It is, in fact, possible. This gets Code.gs:

    function myFunction() {
      throw ScriptApp.getResource("Code").getDataAsString();
    }