multi-clasp2
Version:
Google Clasp wrapper to push changes to multiple Apps Script projects at once.
48 lines • 2.47 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getRunClaspArgs = getRunClaspArgs;
const common_1 = require("./common");
const utils_1 = require("./utils");
/**
* Get Clasp Arguments.
*
* @param functionName {string} The function name within the Apps Script project.
* @param options.nondev {boolean} If we want to run the last deployed version vs the latest code.
* @param options.params {string} JSON string of parameters to be input to function.
* @returns {string} the command arguments
*/
function getRunClaspArgs(functionName = "", options) {
let claspArgs = functionName || "";
const { params: jsonString = '[]' } = options;
const parameters = (0, utils_1.parseJsonOrDie)(jsonString);
if (!options) {
return claspArgs;
}
claspArgs += options.nondev ? " --nondev" : "";
claspArgs += " --params '" + JSON.stringify(parameters) + "'";
return claspArgs;
}
/**
* Executes an Apps Script function. Requires clasp login --creds.
* @param functionName {string} The function name within the Apps Script project.
* @param options.nondev {boolean} If we want to run the last deployed version vs the latest code.
* @param options.params {string} JSON string of parameters to be input to function.
* @see https://developers.google.com/apps-script/api/how-tos/execute
* @requires `clasp login --creds` to be run beforehand.
*/
exports.default = (functionName, options) => __awaiter(void 0, void 0, void 0, function* () {
const claspArgs = getRunClaspArgs(functionName, options);
(0, common_1.foreachClasp)((claspConfig) => __awaiter(void 0, void 0, void 0, function* () {
yield (0, common_1.runClasp)(claspConfig, process.argv[2], claspArgs);
}));
});
//# sourceMappingURL=run.js.map