Skip to content

Instantly share code, notes, and snippets.

@bfitzpat
Created January 8, 2020 20:38
Show Gist options
  • Select an option

  • Save bfitzpat/847e45f2a59a398b7a99fe2451cd3da2 to your computer and use it in GitHub Desktop.

Select an option

Save bfitzpat/847e45f2a59a398b7a99fe2451cd3da2 to your computer and use it in GitHub Desktop.
getCurrentFolder v2
function getCurrentFolder(): Promise<string> {
return new Promise(async (resolve, reject) => {
await vscode.commands.executeCommand('workbench.view.explorer').then( async () => {
await vscode.commands.executeCommand('copyFilePath').then(async () => {
try {
await vscode.env.clipboard.readText().then((copyPath) => {
try {
if (fs.existsSync(copyPath)) {
resolve(copyPath);
return copyPath;
}
} catch (err) {
reject(err);
return undefined;
}
});
} catch (err) {
reject(err);
return undefined;
}
});
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment