npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

tgas-local

v1.1.1

Published

Typescript support for running and testing GAS projects locally.

Downloads

247

Readme

tgas-local

Typescript support for running and testing Google Apps Script (GAS) projects locally.

Why is this necessary?

This project is inspired by the project gas-local, but adds typescript support and modern module syntax. It is frustrating to have to compile your typescript files to javascript after any change in order to run tests on your local apps script files. This package removes that time consuming step, speeding up your development and testing process. Using this package allows you to run and test your apps script files locally in a node environment without needing to make any changes to the files before pushing or pulling your code to the apps script cloud environment using clasp.

Installation

Install this package and the types package for google apps scripts

Via npm

npm i -D tgas-local @types/google-apps-script

Via pnpm

pnpm i -D tgas-local @types/google-apps-script

Optional Plugin

This plugin adds type checking for the return object from gasRequire()

pnpm i -D typescript-plugin-tgas-local

Then add this plugin information to "compilerOptions" in your tsconfig.json file.

{
  // rest of your compilerOptions
  "plugins": [
    {
      "name": "typescript-plugin-tgas-local",
      "apps-script-directory": "./RELATIVE_PATH_TO_YOUR_GAS_FILES"
    }
  ]
}

Usage

// import the gasRequire function
import { gasRequire } from 'tgas-local'

// Pass the relative path from your current working directory to the directory that includes your apps script files.
const gLib = gasRequire('./path-to-local-googleappsscript-directory')

// Call your apps script functions from the gLib object
gLib.yourAppsScriptFunction()

Mocking Google Services

import { type IGlobalMocksObject, gasRequire } from 'tgas-local'

// Create an object that mocks the functions of an Apps Script Service
const mockServices: IGlobalMocksObject = {
  UrlFetchApp: {
    fetch: () => "fetch called!",
    fetchAll: () => "fetchAll called!"
  }
}
// pass it to gasRequire
const gLib = gasRequire('./appsscript-directory', mockServices)

gLib.UrlFetchApp.fetch() // returns the string "fetch called!"

Filtering

Simple file exclusion

// Use the options object to pass a filter function that will filter any unwanted files
// Note: gasRequire is already setup to only read files with the extentions: .ts, .js, .gs
const options = {
  filter: (filePath: string) => {
    return filePath === "some-file-to-not-include.ts"
  }
}
const gLib = gasRequire('./appscript-directory', mockServices, options)

Custom Glob options

// Accepts any valid parameter of the GlobOptions object from the node-glob library.
const options = {
  globOptions: {
    cwd: './some-other-dir',
    absolute: true
    // ...etc
  }
}

Contributing

Pull requests are welcome! I am always open to collaboration.

Inspired by Mikhail Zagorny's gas-local package, but with built in native typescript support.

Built with esbuild and glob

Useful links