vscode#env TypeScript Examples
The following examples show how to use
vscode#env.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: confirm-authorize-app.ts From al-objid with MIT License | 6 votes |
confirmAuthorizeApp = async () => {
let result = await window.showQuickPick(Object.values(OPTION), {
placeHolder: "Are you sure you want to authorize your app?",
});
switch (result) {
case OPTION.YES:
confirmAgain();
break;
case OPTION.LEARN:
env.openExternal(Uri.parse(URLS.AUTHORIZATION_LEARN));
break;
}
}
Example #2
Source File: extension.ts From vscode-stripe with MIT License | 6 votes |
/**
* Checks for the explicit setting of the EXTENSION_MODE and
* Implcitly checks by using the magic session string. This session value is used whenever an extension
* is running on a development host. https://github.com/microsoft/vscode/issues/10272
*/
function getTelemetry(extensionContext: ExtensionContext) {
if (process.env.EXTENSION_MODE === 'development' || env.sessionId === 'someValue.sessionId') {
console.log('Extension is running in development mode. Not emitting Telemetry');
return new NoOpTelemetry();
} else {
return new StripeAnalyticsServiceTelemetry(extensionContext);
}
}
Example #3
Source File: javaRuntimesUtils.ts From vscode-stripe with MIT License | 6 votes |
async function fromEnv(name: string): Promise<string[]> {
const ret: string[] = [];
const value = process.env[name] || '';
if (!!value) {
const javaHome = await verifyJavaHome(value, JAVAC_FILENAME);
if (javaHome) {
ret.push(javaHome);
}
}
return ret;
}
Example #4
Source File: commands.ts From vscode-cadence with Apache License 2.0 | 6 votes |
setActiveAccount = async (ext: Extension, activeIndex: number): Promise<void> => {
const activeAccount = ext.config.getAccount(activeIndex)
if (activeAccount == null) {
window.showErrorMessage('Failed to switch account: account does not exist.')
.then(() => {}, () => {})
return
}
try {
await ext.api.switchActiveAccount(activeAccount)
ext.config.setActiveAccount(activeIndex)
window.showInformationMessage(
`Switched to account ${activeAccount.fullName()}`,
COPY_ADDRESS
).then((choice) => {
if (choice === COPY_ADDRESS) {
env.clipboard.writeText(`0x${activeAccount.address}`)
.then(() => {}, () => {})
}
}, () => {})
renderExtension(ext)
} catch (err) {
window.showErrorMessage(`Failed to switch account: ${err.message as string}`)
.then(() => {}, () => {})
}
}
Example #5
Source File: stripeSamples.ts From vscode-stripe with MIT License | 6 votes |
/**
* Ask if the user wants to open the sample in the same or new window
*/
private promptOpenFolder = async (postInstallMessage: string, clonePath: string, sampleName: string): Promise<void> => {
const openFolderOptions = {
sameWindow: 'Open in same window',
newWindow: 'Open in new window',
};
const selectedOption = await window.showInformationMessage(
postInstallMessage,
{modal: true},
...Object.values(openFolderOptions),
);
// open the readme file in a new browser window
// cant open in the editor because cannot update user setting 'workbench.startupEditor' from stripe extension
// preview markdown also does not work because opening new workspace will terminate the stripe extension process
env.openExternal(Uri.parse(`https://github.com/stripe-samples/${sampleName}#readme`));
switch (selectedOption) {
case openFolderOptions.sameWindow:
await commands.executeCommand('vscode.openFolder', Uri.file(clonePath), {
forceNewWindow: false,
});
break;
case openFolderOptions.newWindow:
await commands.executeCommand('vscode.openFolder', Uri.file(clonePath), {
forceNewWindow: true,
});
break;
default:
break;
}
};
Example #6
Source File: ActivtyTracking.ts From vscode-drawio with GNU General Public License v3.0 | 6 votes |
private async showFeedbackIfApplicable(): Promise<void> {
const { feedbackUrl, canAskForFeedback } = this.config;
if (!canAskForFeedback || !feedbackUrl) {
return;
}
this.config.markAskedToTest();
const result = await window.showInformationMessage(
`With your feedback on GitHub, the Draw.io extension version ${
this.config.packageJson.versionName ||
this.config.packageJson.version
} can be released as stable soon!`,
{ modal: false },
{
title: `Give Feedback ❤️`,
action: () => {
env.openExternal(feedbackUrl);
},
},
{
title: "Skip For This Build",
action: () => {},
}
);
if (result) {
result.action();
}
}
Example #7
Source File: vscodeUtils.ts From vscode-todo-md with MIT License | 6 votes |
/**
* Opens a link externally using the default application.
*/
export async function followLink(linkString: string) {
if (linkString.startsWith('file:///')) {
return await openFileInEditorByPath(linkString);
} else if (linkString.startsWith('app:///')) {
return await env.openExternal(Uri.parse(linkString.slice(7)));
} else {
return await env.openExternal(Uri.parse(linkString));
}
}
Example #8
Source File: confirm-authorize-app.ts From al-objid with MIT License | 6 votes |
async function confirmAgain() {
let result = await window.showQuickPick(Object.values(OPTION_AGAIN), {
placeHolder: "Sorry for asking, but are you *REALLY* sure?",
});
switch (result) {
case OPTION_AGAIN.YES:
await executeAuthorization();
break;
case OPTION_AGAIN.LEARN:
env.openExternal(Uri.parse(URLS.AUTHORIZATION_LEARN));
break;
}
}
Example #9
Source File: confirm-deauthorize-app.ts From al-objid with MIT License | 6 votes |
confirmDeauthorizeApp = async () => {
let result = await window.showQuickPick(Object.values(OPTION), {
placeHolder: "Are you sure you want to deauthorize your app?",
});
switch (result) {
case OPTION.YES:
executeDeuthorization();
break;
case OPTION.LEARN:
env.openExternal(Uri.parse(URLS.AUTHORIZATION_LEARN));
break;
}
}
Example #10
Source File: confirm-sync-object-ids.ts From al-objid with MIT License | 6 votes |
confirmSyncObjectIds = async (context?: AppCommandContext) => {
let result = await window.showQuickPick(Object.values(OPTION), {
placeHolder: "How would you like to synchronize object ID assignment information with the back end?",
});
switch (result) {
case OPTION.REPLACE:
case OPTION.UPDATE:
commands.executeCommand(NinjaCommand.SyncObjectIds, { merge: result === OPTION.UPDATE }, context?.app.hash);
break;
case OPTION.LEARN:
env.openExternal(Uri.parse(URLS.SYNCHRONIZATION_LEARN));
break;
}
}
Example #11
Source File: HttpStatusHandler.ts From al-objid with MIT License | 6 votes |
//#region 410 Gone
private async appUpgradedV2() {
const response = await window.showErrorMessage(
`Your app or all apps in your workspace have been upgraded to "v2" version of the back end. The "v2" version of the back end requires latest version of ${EXTENSION_NAME}, but you are using an older one. You must update ${EXTENSION_NAME} to v2.0.0 or newer.`,
LABELS.BUTTON_LEARN_MORE
);
if (response === LABELS.BUTTON_LEARN_MORE) {
env.openExternal(Uri.parse("https://vjeko.com/2021/10/01/important-announcement-for-al-object-id-ninja/"));
}
}
Example #12
Source File: ConfigureWithUI.ts From dendron with GNU Affero General Public License v3.0 | 6 votes |
async function getWebviewContent2(opts: { title: string }) {
const port = getExtension().port;
if (_.isUndefined(port)) {
return `<head> Still starting up </head>`;
}
// Makes sure ports are forwarded for remote usage
const fullUri = (
await env.asExternalUri(
Uri.parse(`http://localhost:${port}/workspace/config.html`)
)
).toString();
return `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>${opts.title}</title>
<style>
* {margin:0;padding:0;}
html,
body {height:100%; width:100%; overflow:hidden;}
table {height:100%; width:100%; table-layout:static; border-collapse:collapse;}
iframe {float:left; height:100%; width:100%;}
.header {border-bottom:1px solid #000}
.content {height:100%;}
</style>
</head>
<body>
<iframe width="100%" height="100%" src="${fullUri}"></iframe>
</body>
</html>`;
}
Example #13
Source File: extension.ts From sorbet-lsp with MIT License | 6 votes |
spawnWithBash = (cmd, opts) => {
if (platform().match(/darwin|linux/)) {
// OSX and Linux need to use an explicit login shell in order to find
// the correct Ruby environment through installation managers like rvm
// and rbenv.
var shell = env.shell || '/bin/bash';
if (shell.endsWith('bash') || shell.endsWith('zsh')) {
var shellCmd = shellEscape(cmd);
if (opts['cwd']) {
shellCmd = `${shellEscape(['cd', opts['cwd']])} && ${shellCmd}`;
}
var shellArgs = [shellCmd];
shellArgs.unshift('-c');
shellArgs.unshift('-l');
return child_process.spawn(shell, shellArgs, { shell, ...opts });
} else {
return crossSpawn(cmd.shift(), cmd, opts);
}
} else {
return crossSpawn(cmd.shift(), cmd, opts);
}
}
Example #14
Source File: HttpStatusHandler.ts From al-objid with MIT License | 6 votes |
//#endregion
//#region 503 Service Unavailable
public async handleError503(error: any) {
if (maintenance) {
return;
}
maintenance = true;
const date = new Date(error.headers["retry-after"]);
const diff = date.valueOf() - Date.now();
let buttons = ["OK"];
if (typeof error.error === "string" && error.error.toLowerCase().startsWith("http")) {
buttons.push(LABELS.BUTTON_LEARN_MORE);
}
let response = await window.showInformationMessage(
`AL Object ID Ninja back end is currently undergoing scheduled maintenance. It will be ready again in ${Math.ceil(
diff / 60000
)} minute(s).`,
"OK",
LABELS.BUTTON_LEARN_MORE
);
if (response === LABELS.BUTTON_LEARN_MORE) {
env.openExternal(Uri.parse(error.error.toLowerCase()));
}
}
Example #15
Source File: NextObjectIdCompletionProvider.ts From al-objid with MIT License | 6 votes |
export async function syncIfChosen(app: ALApp, choice: Promise<string | undefined>) {
switch (await choice) {
case LABELS.BUTTON_SYNCHRONIZE:
commands.executeCommand(NinjaCommand.SyncObjectIds, {
skipQuestion: true,
});
break;
case LABELS.BUTTON_LEARN_MORE:
Telemetry.instance.log("docs.learnExtension");
env.openExternal(Uri.parse(URLS.EXTENSION_LEARN));
break;
default:
syncDisabled[app.hash] = true;
if (++syncSkipped > 1) {
if ((await UI.nextId.showNoBackEndConsumptionInfoAlreadySaidNo()) === LABELS.BUTTON_DONT_ASK) {
stopAsking = true;
}
}
break;
}
}
Example #16
Source File: extension.ts From reach-ide with Eclipse Public License 2.0 | 5 votes |
urlHelper = (context, label, url) => {
const disposable = commands.registerCommand(`reach.${label}`, () => {
env.openExternal(Uri.parse(url));
});
context.subscriptions.push(disposable);
}
Example #17
Source File: HttpStatusHandler.ts From al-objid with MIT License | 5 votes |
private handlers410: PropertyBag<Function> = {
GENERIC: () => {
output.log(
`You are attempting to access a back-end endpoint that is no longer supported. Please update ${EXTENSION_NAME}.`,
LogLevel.Info
);
if (oldVersion) {
return;
}
oldVersion = true;
window.showWarningMessage(
`You are using an old version of ${EXTENSION_NAME}. There is no major impact on the functionality, but you should consider updating to have access to all latest features.`,
"OK"
);
},
OLD_VERSION: async () => {
const stateKey = `warnings/OLD_VERSION/${EXTENSION_VERSION}`;
const warned = this._context.globalState.get(stateKey);
if (warned) {
return;
}
output.log(`You are using an old version of ${EXTENSION_NAME}.`, LogLevel.Info);
this._context.globalState.update(stateKey, true);
const response = await window.showWarningMessage(
`You are using an old version of ${EXTENSION_NAME}, and a back-end feature you called is no longer available. Please update ${EXTENSION_NAME} to the latest version.`,
"OK",
LABELS.BUTTON_LEARN_MORE
);
if (response === LABELS.BUTTON_LEARN_MORE) {
env.openExternal(
Uri.parse("https://vjeko.com/why-is-using-old-versions-of-al-object-id-ninja-not-a-good-idea/")
);
}
},
APP_UPGRADED_V2: () => {
if (appUpgradedV2) {
return;
}
appUpgradedV2 = true;
this.appUpgradedV2();
},
};
Example #18
Source File: javaRuntimesUtils.ts From vscode-stripe with MIT License | 5 votes |
async function fromCommonPlaces(): Promise<string[]> {
const ret: string[] = [];
// common place for mac
if (isMac) {
const jvmStore = '/Library/Java/JavaVirtualMachines';
const subfolder = 'Contents/Home';
let jvms: string[] = [];
try {
jvms = await fse.readdir(jvmStore);
} catch (error) {
// ignore
}
for (const jvm of jvms) {
const proposed = path.join(jvmStore, jvm, subfolder);
const javaHome = await verifyJavaHome(proposed, JAVAC_FILENAME);
if (javaHome) {
ret.push(javaHome);
}
}
}
// common place for Windows
if (isWindows) {
const localAppDataFolder = process.env.LOCALAPPDATA
? process.env.LOCALAPPDATA
: path.join(os.homedir(), 'AppData', 'Local');
const possibleLocations: string[] = [
process.env.ProgramFiles && path.join(process.env.ProgramFiles, 'Java'), // Oracle JDK per machine
process.env.ProgramW6432 && path.join(process.env.ProgramW6432, 'Java'), // Oracle JDK per machine
process.env.ProgramFiles && path.join(process.env.ProgramFiles, 'AdoptOpenJDK'), // AdoptOpenJDK per machine
process.env.ProgramW6432 && path.join(process.env.ProgramW6432, 'AdoptOpenJDK'), // AdoptOpenJDK per machine
path.join(localAppDataFolder, 'Programs', 'AdoptOpenJDK'), // AdoptOpenJDK per user
].filter(Boolean) as string[];
const jvmStores = _.uniq(possibleLocations);
for (const jvmStore of jvmStores) {
let jvms: string[] = [];
try {
jvms = await fse.readdir(jvmStore);
} catch (error) {
// ignore
}
for (const jvm of jvms) {
const proposed = path.join(jvmStore, jvm);
const javaHome = await verifyJavaHome(proposed, JAVAC_FILENAME);
if (javaHome) {
ret.push(javaHome);
}
}
}
}
// common place for Linux
if (isLinux) {
const jvmStore = '/usr/lib/jvm';
let jvms: string[] = [];
try {
jvms = await fse.readdir(jvmStore);
} catch (error) {
// ignore
}
for (const jvm of jvms) {
const proposed = path.join(jvmStore, jvm);
const javaHome = await verifyJavaHome(proposed, JAVAC_FILENAME);
if (javaHome) {
ret.push(javaHome);
}
}
}
return ret;
}
Example #19
Source File: javaRuntimesUtils.ts From vscode-stripe with MIT License | 5 votes |
async function fromPath(): Promise<string[]> {
const ret: string[] = [];
const paths = process.env.PATH ? process.env.PATH.split(path.delimiter).filter(Boolean) : [];
for (const p of paths) {
const proposed = path.dirname(p); // remove "bin"
const javaHome = await verifyJavaHome(proposed, JAVAC_FILENAME);
if (javaHome) {
ret.push(javaHome);
}
if (isMac) {
let dir = expandHomeDir(p);
dir = await findLinkedFile(dir);
// on mac, java install has a utility script called java_home
const macUtility = path.join(dir, 'java_home');
if (await fse.pathExists(macUtility)) {
let buffer;
try {
buffer = cp.execSync(macUtility, {cwd: dir});
const absoluteJavaHome = '' + buffer.toString().replace(/\n$/, '');
const verified = await verifyJavaHome(absoluteJavaHome, JAVAC_FILENAME);
if (verified) {
ret.push(absoluteJavaHome);
}
} catch (error) {
// do nothing
}
}
}
}
if (isMac) {
// Exclude /usr, because in macOS Big Sur /usr/bin/javac is no longer symlink.
// See https://github.com/redhat-developer/vscode-java/issues/1700#issuecomment-729478810
return ret.filter((item) => item !== '/usr');
} else {
return ret;
}
}
Example #20
Source File: NewsHandler.ts From al-objid with MIT License | 5 votes |
private navigateToUrl(entry: NewsEntry, button: NewsButton) {
this.dismiss(entry);
env.openExternal(Uri.parse(button.parameter));
}
Example #21
Source File: javaRuntimesUtils.ts From vscode-stripe with MIT License | 5 votes |
export async function getJavaSDKInfo(
context: ExtensionContext,
outputChannel: OutputChannel,
): Promise<JDKInfo> {
let source: string;
let javaVersion: number = 0;
// get java.home from vscode settings config first
let javaHome = workspace.getConfiguration().get<string>(STRIPE_JAVA_HOME) || '';
let sdkInfo = {javaVersion, javaHome};
if (javaHome) {
source = `${STRIPE_JAVA_HOME} variable defined in ${env.appName} settings`;
javaHome = expandHomeDir(javaHome);
if (!(await fse.pathExists(javaHome))) {
outputChannel.appendLine(
`The ${source} points to a missing or inaccessible folder (${javaHome})`,
);
} else if (!(await fse.pathExists(path.resolve(javaHome, 'bin', JAVAC_FILENAME)))) {
let msg: string;
if (await fse.pathExists(path.resolve(javaHome, JAVAC_FILENAME))) {
msg = `'bin' should be removed from the ${source} (${javaHome})`;
} else {
msg = `The ${source} (${javaHome}) does not point to a JDK.`;
}
outputChannel.appendLine(msg);
}
javaVersion = await getJavaVersion(javaHome) || 0;
sdkInfo = {javaHome, javaVersion};
if (javaVersion < REQUIRED_JDK_VERSION) {
await window.showInformationMessage(
`The JDK version specified in your user settings does not meet the minimum required version ${REQUIRED_JDK_VERSION}. \
Do you want to check other installed JDK versions?`, ...['Yes', 'No'])
.then(async (option) => {
if (option === 'Yes') {
sdkInfo = await autoDetectInstalledJDKsAndUpdateConfig(context);
}
}
);
} else {
// do nothing. stripe.java.home defined and meets requriement
}
} else {
sdkInfo = await autoDetectInstalledJDKsAndUpdateConfig(context);
}
return sdkInfo;
}
Example #22
Source File: Backend.ts From al-objid with MIT License | 5 votes |
(async () => {
if (Config.instance.isBackEndConfigInError) {
if ((await UI.general.showBackEndConfigurationError()) === LABELS.BUTTON_LEARN_MORE) {
env.openExternal(Uri.parse("https://github.com/vjekob/al-objid/blob/master/doc/DeployingBackEnd.md"));
}
}
})();
Example #23
Source File: SignIn.ts From dendron with GNU Affero General Public License v3.0 | 5 votes |
async execute() {
env.openExternal(
Uri.parse(
"https://auth.dendron.so/login?client_id=7uamhg5vcchlrb149k1bs9k48i&response_type=code&scope=aws.cognito.signin.user.admin+email+openid+phone+profile&redirect_uri=https://app.dendron.so"
)
);
}
Example #24
Source File: local.ts From cloudmusic-vscode with MIT License | 5 votes |
export function initLocal(context: ExtensionContext): void {
context.globalState
.get<readonly string[]>(LOCAL_FOLDER_KEY)
?.forEach((folder) => LocalProvider.folders.push(folder));
context.subscriptions.push(
commands.registerCommand("cloudmusic.newLocalLibrary", async () => {
const path = (
await window.showOpenDialog({
canSelectFiles: false,
canSelectFolders: true,
canSelectMany: false,
})
)?.shift()?.fsPath;
if (!path) return;
try {
if (!LocalProvider.folders.includes(path)) {
LocalProvider.folders.push(path);
await context.globalState.update(
LOCAL_FOLDER_KEY,
LocalProvider.folders
);
LocalProvider.refresh();
}
} catch {}
}),
commands.registerCommand("cloudmusic.refreshLocalLibrary", () =>
LocalProvider.refresh()
),
commands.registerCommand(
"cloudmusic.deleteLocalLibrary",
({ label }: LocalLibraryTreeItem) => {
const idx = LocalProvider.folders.indexOf(label);
LocalProvider.folders.splice(idx, 1);
LocalProvider.refresh();
}
),
commands.registerCommand(
"cloudmusic.openLocalLibrary",
({ label }: LocalLibraryTreeItem) =>
void env.openExternal(Uri.file(label))
),
commands.registerCommand(
"cloudmusic.playLocalLibrary",
async (element: LocalLibraryTreeItem) => {
const items = await LocalProvider.refreshLibrary(element);
IPC.new(items);
}
),
commands.registerCommand(
"cloudmusic.addLocalLibrary",
async (element: LocalLibraryTreeItem) => {
const items = await LocalProvider.refreshLibrary(element);
IPC.add(items);
}
),
commands.registerCommand(
"cloudmusic.refreshLocalFile",
(element: LocalLibraryTreeItem) =>
LocalProvider.refreshLibrary(element, true)
),
commands.registerCommand(
"cloudmusic.addLocalFile",
({ data }: LocalFileTreeItem) => IPC.add([data])
),
commands.registerCommand(
"cloudmusic.playLocalFile",
({ data }: LocalFileTreeItem) => IPC.new([data])
)
);
}
Example #25
Source File: radio.ts From cloudmusic-vscode with MIT License | 5 votes |
export function initRadio(context: ExtensionContext): void {
context.subscriptions.push(
commands.registerCommand(
"cloudmusic.refreshRadio",
(element: UserTreeItem) => RadioProvider.refreshUser(element)
),
commands.registerCommand(
"cloudmusic.refreshRadioContent",
(element: RadioTreeItem) => RadioProvider.refreshRadioHard(element)
),
commands.registerCommand(
"cloudmusic.playRadio",
async (element: RadioTreeItem) => {
const items = await RadioProvider.refreshRadio(element);
IPC.new(items);
}
),
commands.registerCommand(
"cloudmusic.addRadio",
async (element: RadioTreeItem) => {
const items = await RadioProvider.refreshRadio(element);
IPC.add(items);
}
),
commands.registerCommand(
"cloudmusic.unsubRadio",
({ item: { id } }: RadioTreeItem) => IPC.netease("djSub", [id, "unsub"])
),
commands.registerCommand(
"cloudmusic.radioDetail",
({ item }: RadioTreeItem) =>
void MultiStepInput.run((input) => pickRadio(input, 1, item))
),
commands.registerCommand(
"cloudmusic.addProgram",
({ data }: ProgramTreeItem) => IPC.add([data])
),
commands.registerCommand(
"cloudmusic.copyRadioLink",
({ item: { id } }: RadioTreeItem) =>
void env.clipboard.writeText(`https://music.163.com/#/djradio?id=${id}`)
),
commands.registerCommand(
"cloudmusic.programComment",
({ data: { id }, label }: ProgramTreeItem) =>
Webview.comment(NeteaseCommentType.dj, id, label)
),
commands.registerCommand(
"cloudmusic.copyProgramLink",
({ data: { id } }: ProgramTreeItem) =>
void env.clipboard.writeText(`https://music.163.com/#/program?id=${id}`)
)
);
}
Example #26
Source File: index.ts From cloudmusic-vscode with MIT License | 5 votes |
lang = availableLanguages.find((value) => env.language === value)
Example #27
Source File: Contribute.ts From dendron with GNU Affero General Public License v3.0 | 5 votes |
async execute() {
env.openExternal(
Uri.parse("https://accounts.dendron.so/account/subscribe")
);
}
Example #28
Source File: OpenLink.ts From dendron with GNU Affero General Public License v3.0 | 5 votes |
async execute(opts?: { uri?: string }) {
const ctx = DENDRON_COMMANDS.OPEN_LINK;
this.L.info({ ctx });
let text = "";
text = opts?.uri ?? getURLAt(VSCodeUtils.getActiveTextEditor());
if (_.isUndefined(text) || text === "") {
const error = DendronError.createFromStatus({
status: ERROR_STATUS.INVALID_STATE,
message: `no valid path or URL selected`,
});
this.L.error({ error });
return { error };
}
let assetPath: string;
if (
text.indexOf(":/") !== -1 ||
text.indexOf("/") === 0 ||
text.indexOf(":\\") !== -1
) {
window.showInformationMessage(
"the selection reads as a full URI or filepath so an attempt will be made to open it"
);
env.openExternal(Uri.parse(text.replace("\\", "/"))); // make sure vscode doesn't choke on "\"s
assetPath = text;
} else {
const wsRoot = getDWorkspace().wsRoot;
if (text.startsWith("asset")) {
const vault = PickerUtilsV2.getOrPromptVaultForOpenEditor();
assetPath = path.join(vault2Path({ vault, wsRoot }), text);
} else {
assetPath = resolvePath(text, getExtension().rootWorkspace.uri.fsPath);
}
if (!fs.existsSync(assetPath)) {
const error = DendronError.createFromStatus({
status: ERROR_STATUS.INVALID_STATE,
message: `no valid path or URL selected`,
});
this.L.error({ error });
return { error };
}
await open(assetPath).catch((err) => {
const error = DendronError.createFromStatus({
status: ERROR_STATUS.UNKNOWN,
innerError: err,
});
this.L.error({ error });
return { error };
});
}
return { filepath: assetPath };
}
Example #29
Source File: ShowHelp.ts From dendron with GNU Affero General Public License v3.0 | 5 votes |
async execute() {
env.openExternal(
Uri.parse(
"https://www.dendron.so/notes/f9540bb6-7a5a-46db-ae7c-e1a606f28c73.html"
)
);
}