@google/clasp
Version:
Develop Apps Script Projects locally
24 lines (23 loc) • 967 B
JavaScript
import { Command } from 'commander';
import { INCLUDE_USER_HINT_IN_URL } from '../experiments.js';
import { intl } from '../intl.js';
import { openUrl } from './utils.js';
export const command = new Command('open-script')
.arguments('[scriptId]')
.description('Open the Apps Script IDE for the current project.')
.action(async function (scriptId) {
const clasp = this.opts().clasp;
if (!scriptId) {
scriptId = clasp.project.scriptId;
}
if (!scriptId) {
const msg = intl.formatMessage({ id: "RXEA+0", defaultMessage: [{ type: 0, value: "Script ID not set, unable to open IDE." }] });
this.error(msg);
}
const url = new URL(`https://script.google.com/d/${scriptId}/edit`);
if (INCLUDE_USER_HINT_IN_URL) {
const userHint = await clasp.authorizedUser();
url.searchParams.set('authUser', userHint !== null && userHint !== void 0 ? userHint : '');
}
await openUrl(url.toString());
});