Run your google appscript code on your local machine for testing
$ npm install gas-module
fileName
- name or path of file to be importedoptions
(optional)mocks
- object containing mock variables and functions
dirName
- name or path of directory containing files to be importedrecursion
true
to import files from subdirectories toofalse
to ignore subdirectories
options
(optional)filterExtension
['.js']
for files with .js extension (default if leftundefined
)['.ts']
for files with .ts extension['.js', '.ts']
for files with .js and .ts extensions
mocks
- object containing mock variables and functionsorder
- array of filenames in desired order of execusion, if there is files that is not in the array, it will be executed after
const { requireFile } = require('gas-module');
const file = requireFile('filename.js');
//run function defined in file
file.myFunction();
const { requireFile } = require('gas-module');
const mock = {
editor: 'vscode',
hotel: 'trivago'
}
const file = requireFile('filename.js', { mocks: mock});
// run function defined in file
file.myFunction();
// use mock varibale
console.log(file.editor);
const { requireDir } = require('gas-module');
const functions = requireDir('directoryname', false, { filterExtension: ['.js']})
// run function defined in any file
functions.myFunction();
const { requireDir } = require('gas-module');
const functions = requireDir('directoryname', true, { filterExtension: ['.ts']})
// run function defined in any file
functions.myFunction();
const { requireDir } = require('gas-module');
const functions = requireDir('directoryname', true, { filterExtension: ['.js', '.ts']})
// run function defined in any file
functions.myFunction();
const { requireDir } = require('gas-module');
const mock = {
editor: 'vscode',
hotel: 'trivago'
}
const file = requireDir('directoryname', false, { mocks: mock});
// run function defined in file
file.myFunction();
// use mock varibale
console.log(file.editor);