Git Product home page Git Product logo

gas-entry-generator's Introduction

gas-entry-generator NPM version Build Status Dependency Status  Coverage percentage

Top level function generator for Google Apps Script.

About

In Google Apps Script, it must be top level function declaration that entry point called from google.script.run. gas-entry-generator generate a top level function declaration statement, when it detect a function assignment expression to global object.

Installation

$ npm install gas-entry-generator --save-dev

example

foo.js:

/**
 * comment for foo function.
 */
global.foo = function () {
};

generate.js:

const fs = require('fs');
const { generate } = require('gas-entry-generator');

const fooSource = fs.readFileSync('foo.js', {encoding: 'utf8'});
const options = {
  comment: true
};
const output = generate(fooSource, options);
console.log(output.entryPointFunctions);

Console output:

/**
 * comment for foo function.
 */
function foo() {
}

Execute to generate function as entry point.

$ node generate.js

geranate global assignment expressions from exports.*

foo.ts:

/**
 * comment for foo function.
 */
exports.foo = () => 'bar';

generate.js:

const fs = require('fs');
const { generate } = require('gas-entry-generator');

const fooSource = fs.readFileSync('foo.js', {encoding: 'utf8'});
const options = {
  comment: true,
  autoGlobalExports: true // Enable to detect exports.* to generate entry point functions.
};
const output = generate(fooSource, options);
console.log(output.entryPointFunctions);
console.log('-----');
console.log(output.globalAssignments);

Console output:

/**
 * comment for foo function.
 */
function foo() {
}
-----
global.foo = exports.foo;

gas-entry-generator's People

Contributors

dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar fossamagna avatar greenkeeper[bot] avatar karelmaxa avatar marcomow avatar motin avatar x746e avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.