@google/clasp
Version:
Develop Apps Script Projects locally
22 lines (21 loc) • 940 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-container')
.description('Open the Apps Script IDE for the current project.')
.action(async function () {
const clasp = this.opts().clasp;
const parentId = clasp.project.parentId;
if (!parentId) {
const msg = intl.formatMessage({ id: "eXBzoP", defaultMessage: [{ type: 0, value: "Parent ID not set, unable to open document." }] });
this.error(msg);
}
const url = new URL('https://drive.google.com/open');
url.searchParams.set('id', parentId);
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());
});